GuiMove module

GuiMove: Minecraft 26.3 cheat module, full source for every implementation (2 clients: MelaHack (ThunderHack fork), OfflineClient).

2 implementationsMOVEMENTPLAYER

Full module source: 2 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

MelaHack (ThunderHack fork)MOVEMENTsrc/main/java/thunder/hack/features/modules/movement/GuiMove.javaJava · 176 lines · 7.4 KB

Allows you to move while in the gui.

SettingsBypassRotateOnArrowssneakCloseWithoutPacketCloseAndReopenBind
GuiMove.javaJava · Minecraft 26.2 · 176 lines · 7.4 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.movement;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.client.KeyMapping;
5
import net.minecraft.client.gui.screens.ChatScreen;
6
import net.minecraft.client.gui.screens.Screen;
7
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
8
import net.minecraft.network.protocol.game.ServerboundContainerClosePacket;
9
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
10
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
11
import net.minecraft.world.inventory.AbstractContainerMenu;
12
import net.minecraft.world.inventory.ContainerInput;
13
import org.lwjgl.glfw.GLFW;
14
import thunder.hack.events.impl.EventClickSlot;
15
import thunder.hack.events.impl.PacketEvent;
16
import thunder.hack.features.modules.Module;
17
import thunder.hack.setting.Setting;
18
import thunder.hack.setting.impl.Bind;
19
import thunder.hack.setting.impl.BooleanSettingGroup;
20
import thunder.hack.utility.Timer;
21
import thunder.hack.utility.player.MovementUtility;
22
23
import java.util.LinkedList;
24
import java.util.Queue;
25
import java.util.concurrent.atomic.AtomicBoolean;
26
27
import static thunder.hack.features.modules.client.ClientSettings.isRu;
28
29
import com.mojang.blaze3d.platform.InputConstants;
30
31
public class GuiMove extends Module {
32
    public GuiMove() {
33
        super("GuiMove", Category.MOVEMENT);
34
    }
35
36
    private final Setting<Bypass> clickBypass = new Setting<>("Bypass", Bypass.None);
37
    private final Setting<Boolean> rotateOnArrows = new Setting<>("RotateOnArrows", true);
38
    private final Setting<Boolean> sneak = new Setting<>("sneak", false);
39
    private final Setting<BooleanSettingGroup> closeWithoutPacketGroup = new Setting<>("CloseWithoutPacket", new BooleanSettingGroup(false), v -> true);
40
    private final Setting<Bind> closeBind = new Setting<>("CloseAndReopenBind", new Bind(GLFW.GLFW_KEY_B, false, false), v -> true).addToGroup(closeWithoutPacketGroup);
41
42
    private Screen screen;
43
    private AbstractContainerMenu screenHandler;
44
    private Timer bindDelay = new Timer();
45
46
    private final Queue<ServerboundContainerClickPacket> storedClicks = new LinkedList<>();
47
    private AtomicBoolean pause = new AtomicBoolean();
48
49
    @Override
50
    public void onUpdate() {
51
        if (mc.gui.screen() != null && !(mc.gui.screen() instanceof ChatScreen)) {
52
            for (KeyMapping k : new KeyMapping[]{mc.options.keyUp, mc.options.keyDown, mc.options.keyLeft, mc.options.keyRight, mc.options.keyJump, mc.options.keySprint})
53
                k.setDown(isKeyPressed(InputConstants.getKey(k.saveString()).getValue()));
54
55
            float deltaX = 0;
56
            float deltaY = 0;
57
58
            if (rotateOnArrows.getValue()) {
59
                if (isKeyPressed(264))
60
                    deltaY += 30f;
61
62
                if (isKeyPressed(265))
63
                    deltaY -= 30f;
64
65
                if (isKeyPressed(262))
66
                    deltaX += 30f;
67
68
                if (isKeyPressed(263))
69
                    deltaX -= 30f;
70
71
                if (deltaX != 0 || deltaY != 0)
72
                    mc.player.turn(deltaX, deltaY);
73
            }
74
75
            if (sneak.getValue())
76
                mc.options.keyShift.setDown(isKeyPressed(InputConstants.getKey(mc.options.keyShift.saveString()).getValue()));
77
78
        }
79
80
        if (closeWithoutPacketGroup.getValue().isEnabled()) {
81
            closeWithoutPacket();
82
        }
83
    }
84
85
    // thanks ui utils for this!
86
    public void closeWithoutPacket() {
87
        if (isKeyPressed(closeBind) && bindDelay.every(250)) {
88
89
            if (mc.gui.screen() instanceof ChatScreen) {
90
                return;
91
            }
92
93
            if (mc.gui.screen() != null) {
94
                screen = mc.gui.screen();
95
                screenHandler = mc.player.containerMenu;
96
                mc.gui.setScreen(null);
97
                if (mc.gui.screen() != screen) sendMessage(isRu() ? "Интерфейс сохранен! Нажмите еще раз чтобы открыть" : "GUI have been saved! Press again to open.");
98
            } else {
99
                mc.gui.setScreen(screen);
100
                mc.player.containerMenu = screenHandler;
101
                sendMessage(isRu() ? "Интерфейс открыт." : "GUI Opened.");
102
            }
103
104
        }
105
    }
106
107
    @EventHandler
108
    public void onClickSlot(EventClickSlot e) {
109
        if (clickBypass.is(Bypass.DisableClicks) && (MovementUtility.isMoving() || mc.options.keyJump.isDown()))
110
            e.cancel();
111
    }
112
113
    @EventHandler
114
    public void onPacketSend(PacketEvent.Send e) {
115
        if (!MovementUtility.isMoving() || !mc.options.keyJump.isDown() || pause.get())
116
            return;
117
118
        if (e.getPacket() instanceof ServerboundContainerClickPacket click) {
119
            switch (clickBypass.getValue()) {
120
                case GrimSwap -> {
121
                    if (click.containerInput() != ContainerInput.PICKUP && click.containerInput() != ContainerInput.PICKUP_ALL)
122
                        sendPacket(new ServerboundContainerClosePacket(0));
123
                }
124
125
                case StrictNCP -> {
126
                    if (mc.player.onGround() && !mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().move(0.0, 0.0656, 0.0)).iterator().hasNext()) {
127
                        if (mc.player.isSprinting())
128
                            sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.STOP_SPRINTING));
129
                        sendPacket(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + 0.0656, mc.player.getZ(), false, mc.player.horizontalCollision));
130
                    }
131
                }
132
133
                case StrictNCP2 -> {
134
                    if (mc.player.onGround() && !mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().move(0.0, 0.000000271875, 0.0)).iterator().hasNext()) {
135
                        if (mc.player.isSprinting())
136
                            sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.STOP_SPRINTING));
137
                        sendPacket(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + 0.000000271875, mc.player.getZ(), false, mc.player.horizontalCollision));
138
                    }
139
                }
140
141
                case MatrixNcp -> {
142
                    sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.STOP_SPRINTING));
143
                    mc.options.keyUp.setDown(false);
144
                    MovementUtility.setMovementInputY(0f);
145
                }
146
147
                case Delay -> {
148
                    storedClicks.add(click);
149
                    e.cancel();
150
                }
151
            }
152
        }
153
154
        if (e.getPacket() instanceof ServerboundContainerClosePacket) {
155
            if (clickBypass.is(Bypass.Delay)) {
156
                pause.set(true);
157
                while (!storedClicks.isEmpty())
158
                    sendPacket(storedClicks.poll());
159
                pause.set(false);
160
            }
161
        }
162
    }
163
164
    @EventHandler
165
    public void onPacketSendPost(PacketEvent.SendPost e) {
166
        if (e.getPacket() instanceof ServerboundContainerClickPacket) {
167
            if (mc.player.isSprinting() && clickBypass.is(Bypass.StrictNCP))
168
                sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_SPRINTING));
169
        }
170
    }
171
172
    private enum Bypass {
173
        DisableClicks, None, StrictNCP, GrimSwap, MatrixNcp, Delay, StrictNCP2
174
    }
175
}
176
OfflineClientPLAYERsrc/main/java/com/jellypudding/offlineclient/modules/player/GUIMove.javaJava · 176 lines · 6.4 KB

Lets you look around whilst a chest or inventory is open.

SettingsModeHold keyArrow keysTurn speed
GUIMove.javaJava · Minecraft 26.2 · 176 lines · 6.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.player;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.ClientTickEvent;
5
import com.jellypudding.offlineclient.event.events.Render3DEvent;
6
import com.jellypudding.offlineclient.gui.GuiScreenBase;
7
import com.jellypudding.offlineclient.module.Category;
8
import com.jellypudding.offlineclient.module.Module;
9
import com.jellypudding.offlineclient.modules.render.Freecam;
10
import com.jellypudding.offlineclient.setting.BoolSetting;
11
import com.jellypudding.offlineclient.setting.EnumSetting;
12
import com.jellypudding.offlineclient.setting.KeybindSetting;
13
import com.jellypudding.offlineclient.setting.NumberSetting;
14
import com.jellypudding.offlineclient.util.InputUtil;
15
import com.jellypudding.offlineclient.util.Modules;
16
import com.mojang.blaze3d.platform.InputConstants;
17
import net.minecraft.client.gui.screens.Screen;
18
import net.minecraft.util.Mth;
19
20
import java.util.Locale;
21
import org.lwjgl.glfw.GLFW;
22
23
// Turns the camera whilst a chest or inventory is open. Hold mode leaves the
24
// pointer free for clicking. InvWalk covers walking about.
25
public final class GUIMove extends Module {
26
27
    public enum Mode { HOLD_KEY, ALWAYS, ARROWS_ONLY }
28
29
    // The most degrees one frame may turn however long it took.
30
    private static final float MAX_TURN = 100;
31
32
    private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
33
        "When the mouse turns the view.", Mode.HOLD_KEY)
34
        .describe(Mode.HOLD_KEY, "Turns only whilst the key is held. The pointer stays free for clicking.")
35
        .describe(Mode.ALWAYS, "Turns the whole time the screen is open.")
36
        .describe(Mode.ARROWS_ONLY, "The mouse never turns the view. Only the arrow keys do.");
37
    private final KeybindSetting hold = new KeybindSetting("Hold key",
38
        "Keep this key down to look around.", GLFW.GLFW_KEY_LEFT_ALT)
39
        .under(mode, Mode.HOLD_KEY);
40
    private final BoolSetting arrowKeys = new BoolSetting("Arrow keys",
41
        "The arrow keys turn the view whilst a screen is open.", true);
42
    private final NumberSetting turnSpeed = new NumberSetting("Turn speed",
43
        "Degrees a tick the arrow keys turn you.", 4, 0.5, 20, 0.5, " degrees")
44
        .min(0).under(arrowKeys);
45
46
    private boolean turning;
47
    private double savedX;
48
    private double savedY;
49
50
    public GUIMove() {
51
        super("GUIMove", "Lets you look around whilst a chest or inventory is open.", Category.PLAYER);
52
        addSettings(mode, hold, arrowKeys, turnSpeed);
53
        searchTags("gui move", "inv rotate", "menu look", "inventory look");
54
    }
55
56
    // The mouse mixin reads this to hide the screen from the movement handler.
57
    public boolean isTurning() {
58
        return isEnabled() && turning;
59
    }
60
61
    // Read by ScreenMixin. The arrow keys must not move the focus about instead.
62
    public boolean takesArrows() {
63
        return isEnabled() && arrowKeys.isOn() && mc.gui.screen() != null
64
            && allowed(mc.gui.screen());
65
    }
66
67
    @Override
68
    public String getSuffix() {
69
        if (turning) {
70
            return "turning";
71
        }
72
        if (!mode.is(Mode.HOLD_KEY)) {
73
            return mode.getValueString().toLowerCase(Locale.ROOT);
74
        }
75
        // Naming the key here is the only hint most people get.
76
        return hold.isBound() ? hold.getKeyName().toLowerCase(Locale.ROOT) : "no key";
77
    }
78
79
    @Override
80
    protected void onDisable() {
81
        stopTurning();
82
    }
83
84
    @Subscribe
85
    private void onClientTick(ClientTickEvent event) {
86
        if (!inGame()) {
87
            stopTurning();
88
            return;
89
        }
90
        Screen screen = mc.gui.screen();
91
        if (screen == null || !allowed(screen) || mode.is(Mode.ARROWS_ONLY)) {
92
            stopTurning();
93
            return;
94
        }
95
        if (mode.is(Mode.ALWAYS) || hold.isHeld()) {
96
            startTurning();
97
        } else {
98
            stopTurning();
99
        }
100
    }
101
102
    // Runs every frame. The turn is smooth however slow the ticks are.
103
    @Subscribe
104
    private void onRender3D(Render3DEvent event) {
105
        if (!arrowKeys.isOn() || !inGame()) {
106
            return;
107
        }
108
        Screen screen = mc.gui.screen();
109
        if (screen == null || !allowed(screen)) {
110
            return;
111
        }
112
        float step = Math.min((float) (turnSpeed.getValue() * mc.getDeltaTracker().getRealtimeDeltaTicks()), MAX_TURN);
113
        float yaw = 0;
114
        float pitch = 0;
115
        if (arrowDown(GLFW.GLFW_KEY_LEFT)) {
116
            yaw -= step;
117
        }
118
        if (arrowDown(GLFW.GLFW_KEY_RIGHT)) {
119
            yaw += step;
120
        }
121
        if (arrowDown(GLFW.GLFW_KEY_UP)) {
122
            pitch -= step;
123
        }
124
        if (arrowDown(GLFW.GLFW_KEY_DOWN)) {
125
            pitch += step;
126
        }
127
        if (yaw == 0 && pitch == 0) {
128
            return;
129
        }
130
        Freecam freecam = Modules.get(Freecam.class);
131
        if (freecam != null && freecam.movesCamera()) {
132
            // Freecam scales its turn the way the mouse handler does.
133
            freecam.turn(yaw / InputUtil.MOUSE_TURN, pitch / InputUtil.MOUSE_TURN);
134
            return;
135
        }
136
        mc.player.setYRot(mc.player.getYRot() + yaw);
137
        mc.player.setXRot(Mth.clamp(mc.player.getXRot() + pitch, -90, 90));
138
    }
139
140
    private boolean arrowDown(int key) {
141
        return InputConstants.isKeyDown(mc.getWindow(), key);
142
    }
143
144
    // The client's own screens need the pointer for clicking.
145
    private static boolean allowed(Screen screen) {
146
        return !(screen instanceof GuiScreenBase) && InvWalk.walkable(screen);
147
    }
148
149
    private void startTurning() {
150
        if (turning || mc.getWindow() == null || mc.mouseHandler.isMouseGrabbed()) {
151
            return;
152
        }
153
        turning = true;
154
        // The pointer comes back to this position on release.
155
        savedX = mc.mouseHandler.xpos();
156
        savedY = mc.mouseHandler.ypos();
157
        mc.mouseHandler.setIgnoreFirstMove();
158
        InputConstants.grabOrReleaseMouse(mc.getWindow(),
159
            InputConstants.CURSOR_DISABLED, savedX, savedY);
160
    }
161
162
    private void stopTurning() {
163
        if (!turning) {
164
            return;
165
        }
166
        turning = false;
167
        // Closing the screen makes the game take the pointer back in the same tick.
168
        if (mc.getWindow() == null || mc.mouseHandler.isMouseGrabbed()) {
169
            return;
170
        }
171
        mc.mouseHandler.setIgnoreFirstMove();
172
        InputConstants.grabOrReleaseMouse(mc.getWindow(),
173
            InputConstants.CURSOR_NORMAL, savedX, savedY);
174
    }
175
}
176