auto-walk module

auto-walk: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationMovement

Clients with this module

Full module source: 1 implementation

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

Meteor ClientMovementsrc/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWalk.javaJava · 193 lines · 6.6 KB

Automatically walks forward.

Settingsmodesimple-directiondisable-on-inputdisable-on-y-changeno-unloaded-chunks
AutoWalk.javaJava · Minecraft 26.2 · 193 lines · 6.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.movement;
7
8
import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
9
import meteordevelopment.meteorclient.events.meteor.KeyInputEvent;
10
import meteordevelopment.meteorclient.events.meteor.MouseClickEvent;
11
import meteordevelopment.meteorclient.events.world.TickEvent;
12
import meteordevelopment.meteorclient.mixininterface.IVec3;
13
import meteordevelopment.meteorclient.pathing.NopPathManager;
14
import meteordevelopment.meteorclient.pathing.PathManagers;
15
import meteordevelopment.meteorclient.settings.BoolSetting;
16
import meteordevelopment.meteorclient.settings.EnumSetting;
17
import meteordevelopment.meteorclient.settings.Setting;
18
import meteordevelopment.meteorclient.settings.SettingGroup;
19
import meteordevelopment.meteorclient.systems.modules.Categories;
20
import meteordevelopment.meteorclient.systems.modules.Module;
21
import meteordevelopment.meteorclient.systems.modules.Modules;
22
import meteordevelopment.meteorclient.utils.Utils;
23
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
24
import meteordevelopment.orbit.EventHandler;
25
import meteordevelopment.orbit.EventPriority;
26
import net.minecraft.client.input.KeyEvent;
27
import net.minecraft.client.input.MouseButtonEvent;
28
29
public class AutoWalk extends Module {
30
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
31
32
    private final Setting<Mode> mode = sgGeneral.add(new EnumSetting.Builder<Mode>()
33
        .name("mode")
34
        .description("Walking mode.")
35
        .defaultValue(Mode.Smart)
36
        .onChanged(mode1 -> {
37
            if (isActive() && Utils.canUpdate()) {
38
                if (mode1 == Mode.Simple) {
39
                    PathManagers.get().stop();
40
                } else {
41
                    createGoal();
42
                }
43
44
                unpress();
45
            }
46
        })
47
        .build()
48
    );
49
50
    private final Setting<Direction> direction = sgGeneral.add(new EnumSetting.Builder<Direction>()
51
        .name("simple-direction")
52
        .description("The direction to walk in simple mode.")
53
        .defaultValue(Direction.Forwards)
54
        .onChanged(_ -> {
55
            if (isActive()) unpress();
56
        })
57
        .visible(() -> mode.get() == Mode.Simple)
58
        .build()
59
    );
60
61
    private final Setting<Boolean> disableOnInput = sgGeneral.add(new BoolSetting.Builder()
62
        .name("disable-on-input")
63
        .description("Disable module on manual movement input")
64
        .defaultValue(false)
65
        .build()
66
    );
67
68
    private final Setting<Boolean> disableOnY = sgGeneral.add(new BoolSetting.Builder()
69
        .name("disable-on-y-change")
70
        .description("Disable module if player moves vertically")
71
        .defaultValue(false)
72
        .visible(() -> mode.get() == Mode.Simple)
73
        .build()
74
    );
75
76
    private final Setting<Boolean> waitForChunks = sgGeneral.add(new BoolSetting.Builder()
77
        .name("no-unloaded-chunks")
78
        .description("Do not allow movement into unloaded chunks")
79
        .defaultValue(true)
80
        .visible(() -> mode.get() == Mode.Simple)
81
        .build()
82
    );
83
84
    public AutoWalk() {
85
        super(Categories.Movement, "auto-walk", "Automatically walks forward.");
86
    }
87
88
    @Override
89
    public void onActivate() {
90
        if (mode.get() == Mode.Smart) createGoal();
91
    }
92
93
    @Override
94
    public void onDeactivate() {
95
        if (mode.get() == Mode.Simple) unpress();
96
        else PathManagers.get().stop();
97
    }
98
99
    @EventHandler(priority = EventPriority.HIGH)
100
    private void onTick(TickEvent.Pre event) {
101
        if (mode.get() == Mode.Simple) {
102
            if (disableOnY.get() && mc.player.yo != mc.player.getY()) {
103
                toggle();
104
                return;
105
            }
106
107
            switch (direction.get()) {
108
                case Forwards -> mc.options.keyUp.setDown(true);
109
                case Backwards -> mc.options.keyDown.setDown(true);
110
                case Left -> mc.options.keyLeft.setDown(true);
111
                case Right -> mc.options.keyRight.setDown(true);
112
            }
113
        } else {
114
            if (PathManagers.get() instanceof NopPathManager) {
115
                info("Smart mode requires Baritone");
116
                toggle();
117
            }
118
        }
119
    }
120
121
    private void onMovement() {
122
        if (!disableOnInput.get()) return;
123
        if (mc.gui.screen() != null) {
124
            GUIMove guiMove = Modules.get().get(GUIMove.class);
125
            if (!guiMove.isActive()) return;
126
            if (guiMove.skip()) return;
127
        }
128
        toggle();
129
    }
130
131
    @EventHandler
132
    private void onKey(KeyInputEvent event) {
133
        if (isMovementKey(event.input) && event.action == KeyAction.Press) onMovement();
134
    }
135
136
    @EventHandler
137
    private void onMouseClick(MouseClickEvent event) {
138
        if (isMovementButton(event.click) && event.action == KeyAction.Press) onMovement();
139
    }
140
141
    @EventHandler
142
    private void onPlayerMove(PlayerMoveEvent event) {
143
        if (mode.get() == Mode.Simple && waitForChunks.get()) {
144
            int chunkX = (int) ((mc.player.getX() + event.movement.x * 2) / 16);
145
            int chunkZ = (int) ((mc.player.getZ() + event.movement.z * 2) / 16);
146
            if (!mc.level.getChunkSource().hasChunk(chunkX, chunkZ)) {
147
                ((IVec3) event.movement).meteor$set(0, event.movement.y, 0);
148
            }
149
        }
150
    }
151
152
    private void unpress() {
153
        mc.options.keyUp.setDown(false);
154
        mc.options.keyDown.setDown(false);
155
        mc.options.keyLeft.setDown(false);
156
        mc.options.keyRight.setDown(false);
157
    }
158
159
    private boolean isMovementKey(KeyEvent input) {
160
        return mc.options.keyUp.matches(input)
161
            || mc.options.keyDown.matches(input)
162
            || mc.options.keyLeft.matches(input)
163
            || mc.options.keyRight.matches(input)
164
            || mc.options.keyShift.matches(input)
165
            || mc.options.keyJump.matches(input);
166
    }
167
168
    private boolean isMovementButton(MouseButtonEvent click) {
169
        return mc.options.keyUp.matchesMouse(click)
170
            || mc.options.keyDown.matchesMouse(click)
171
            || mc.options.keyLeft.matchesMouse(click)
172
            || mc.options.keyRight.matchesMouse(click)
173
            || mc.options.keyShift.matchesMouse(click)
174
            || mc.options.keyJump.matchesMouse(click);
175
    }
176
177
    private void createGoal() {
178
        PathManagers.get().moveInDirection(mc.player.getYRot());
179
    }
180
181
    public enum Mode {
182
        Simple,
183
        Smart
184
    }
185
186
    public enum Direction {
187
        Forwards,
188
        Backwards,
189
        Left,
190
        Right
191
    }
192
}
193