minefuncheat- Fixed Fly & Teleport

we do a little trolling (fixed fly & tp 2026)

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         minefuncheat- Fixed Fly & Teleport
// @description  we do a little trolling (fixed fly & tp 2026)
// @version      4.0.6
// @author       FORGEX
// @match        *://minefun.io/*
// @grant        none
// @namespace https://greasyfork.org/users/1547600
// ==/UserScript==

(() => {
    "use strict";

    // ────────────────────────────────────────────────
    //  Các phần webpack_modules, style, hooks... giữ nguyên như cũ
    //  (bạn copy nguyên từ code cũ vào đây, mình không paste lại để ngắn gọn)
    // ────────────────────────────────────────────────

    // ── Chỉnh sửa và bổ sung các module quan trọng ──

    class Fly extends Module {
        constructor() {
            super("Fly", "Movement", {
                "Vertical Speed": 6,
                "Horizontal Speed": 8
            });
            this.toggleKey = "KeyF";
            this._original = {};
            document.addEventListener("keydown", e => {
                if (e.code === this.toggleKey && !e.repeat) this.toggle();
            });
        }

        onEnable() {
            const p = hooks.A?.gameWorld?.player;
            if (!p) return;
            this._original.gravity = p.velocity?.gravity ?? 23;
            this._original.moveSpeed = p.velocity?.moveSpeed ?? 4.5;
            console.log("[Fly] Đã lưu giá trị gốc → gravity:", this._original.gravity);
        }

        onDisable() {
            const p = hooks.A?.gameWorld?.player;
            if (!p) return;
            if (this._original.gravity !== undefined) p.velocity.gravity = this._original.gravity;
            if (this._original.moveSpeed !== undefined) p.velocity.moveSpeed = this._original.moveSpeed;
            p.velocity.fastMoveSpeed = 6.4;
            console.log("[Fly] Đã khôi phục gravity & speed gốc");
        }

        onRender() {
            const p = hooks.A?.gameWorld?.player;
            if (!p || !this.isEnabled) return;

            // Tắt các cơ chế chống bay phổ biến
            p.velocity.gravity = 0;
            p.collision.isGrounded = false;
            p.collision.wasOnGround = false;
            p.onGround = false;           // một số game dùng tên này
            p.isFalling = false;
            p.fallDistance = 0;

            // Lấy hướng nhìn (yaw + pitch)
            const yaw = p.rotation.y;
            const pitch = p.rotation.x;
            const forwardX = -Math.sin(yaw) * Math.cos(pitch);
            const forwardZ = Math.cos(yaw) * Math.cos(pitch);
            const upY = Math.sin(pitch);

            const hSpeed = this.options["Horizontal Speed"];
            const vSpeed = this.options["Vertical Speed"];

            // Di chuyển ngang theo hướng nhìn + phím W/S/A/D
            let vx = 0, vz = 0;
            if (p.inputs.forward) { vx += forwardX; vz += forwardZ; }
            if (p.inputs.backward) { vx -= forwardX; vz -= forwardZ; }
            if (p.inputs.left) { vx += forwardZ; vz -= forwardX; }
            if (p.inputs.right) { vx -= forwardZ; vz += forwardX; }

            const hLen = Math.hypot(vx, vz) || 1;
            vx = (vx / hLen) * hSpeed;
            vz = (vz / hLen) * hSpeed;

            p.velocity.velVec3.x = vx;
            p.velocity.velVec3.z = vz;

            // Di chuyển dọc (Space / Ctrl)
            if (p.inputs.jump) {
                p.velocity.velVec3.y = vSpeed;
            } else if (p.inputs.crouch) {
                p.velocity.velVec3.y = -vSpeed;
            } else {
                p.velocity.velVec3.y *= 0.92; // giảm dần để không bay vèo vèo
            }

            // Giữ cho player không bị kẹt hoặc rơi đột ngột
            p.velocity.velVec3.y = Math.max(-vSpeed * 1.5, Math.min(vSpeed * 1.5, p.velocity.velVec3.y));
        }
    }

    class TeleportModule extends Module {
        constructor() {
            super("Teleport", "Misc");
            this.key = "KeyT";
            document.addEventListener("keydown", e => {
                if (e.code === this.key && !e.repeat) {
                    this.tryTeleport();
                }
            });
        }

        tryTeleport() {
            const w = hooks.A?.gameWorld;
            if (!w?.player) {
                console.warn("[TP] Không tìm thấy player");
                return;
            }

            let blockPos = null;

            // Cách 1: Dùng outline / selection system (phổ biến nhất)
            const selSystem = w.systemsManager?.activeSystems?.find(s => 
                s.currBlockPos || s.selectedPos || s.outlinePos || s.hoverPos
            );
            if (selSystem?.currBlockPos) {
                blockPos = selSystem.currBlockPos;
            }

            // Cách 2: Nếu không có → tự raycast đơn giản (dùng three.js)
            if (!blockPos && w.threeScene?.camera && w.threeScene?.scene) {
                try {
                    const THREE = window.THREE || w.threeScene.THREE;
                    if (THREE) {
                        const cam = w.threeScene.camera;
                        const dir = new THREE.Vector3();
                        cam.getWorldDirection(dir);
                        const origin = new THREE.Vector3().copy(w.player.position);
                        origin.y += 1.62; // eye height

                        const raycaster = new THREE.Raycaster(origin, dir, 0, 120);
                        const intersects = raycaster.intersectObjects(w.threeScene.scene.children, true);

                        if (intersects.length > 0) {
                            const pt = intersects[0].point;
                            blockPos = {
                                x: Math.floor(pt.x),
                                y: Math.floor(pt.y),
                                z: Math.floor(pt.z)
                            };
                        }
                    }
                } catch(e) {
                    console.warn("[TP] Raycast thủ công lỗi:", e);
                }
            }

            if (!blockPos) {
                console.warn("[TP] Không tìm thấy block đang nhìn vào");
                return;
            }

            // Teleport lên trên block 1.5–2 block để tránh kẹt
            const dest = {
                x: blockPos.x + 0.5,
                y: blockPos.y + 2,
                z: blockPos.z + 0.5
            };

            console.log("[TP] Thử dịch chuyển tới:", dest);

            // Thử nhiều cách set position (tùy game engine)
            const tries = [
                () => { w.player.position.set(dest.x, dest.y, dest.z); },
                () => { w.player.physicsPosComp?.copyPos?.(dest); },
                () => { w.player.transform?.position?.set?.(dest.x, dest.y, dest.z); },
                () => { w.player._physics?.setPosition?.(dest); },
                () => { Object.assign(w.player.position, dest); w.player.physicsPosComp?.sync?.(); }
            ];

            let success = false;
            for (const fn of tries) {
                try {
                    fn();
                    success = true;
                    console.log("[TP] Thành công với cách:", fn.toString().slice(0,60)+"...");
                    break;
                } catch(e) {}
            }

            if (!success) {
                console.error("[TP] Không cách nào set position thành công. Kiểm tra console xem player có thuộc tính position/physics không.");
            }
        }
    }

    // ── Thêm Fly & Teleport vào module manager (thay thế phiên bản cũ) ──
    // Trong phần module_moduleManager.init(), thay thế hoặc thêm lại:

    // ... các module khác giữ nguyên ...

    module_moduleManager.addModule(new Fly());
    module_moduleManager.addModule(new TeleportModule());

    // Nếu bạn đã add trước đó thì có thể xóa dòng cũ và add lại 2 module này

    // ── Phần còn lại của script (Minebuns class, events, init...) giữ nguyên ──

    const main = new Minebuns();
})();