Skip to content

Add some QoL options to auto-walk #5440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@

package meteordevelopment.meteorclient.systems.modules.movement;

import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
import meteordevelopment.meteorclient.events.meteor.KeyEvent;
import meteordevelopment.meteorclient.events.meteor.MouseButtonEvent;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.mixininterface.IVec3d;
import meteordevelopment.meteorclient.pathing.NopPathManager;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.settings.EnumSetting;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.GUIMove;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.misc.input.Input;
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
import meteordevelopment.orbit.EventHandler;
import meteordevelopment.orbit.EventPriority;
import net.minecraft.client.option.KeyBinding;
Expand Down Expand Up @@ -51,6 +58,29 @@ public class AutoWalk extends Module {
.build()
);

private final Setting<Boolean> disableOnInput = sgGeneral.add(new BoolSetting.Builder()
.name("disable-on-input")
.description("Disable module on manual movement input")
.defaultValue(false)
.build()
);

private final Setting<Boolean> disableOnY = sgGeneral.add(new BoolSetting.Builder()
.name("disable-on-y-change")
.description("Disable module if player moves vertically")
.defaultValue(false)
.visible(() -> mode.get() == Mode.Simple)
.build()
);

private final Setting<Boolean> waitForChunks = sgGeneral.add(new BoolSetting.Builder()
.name("no-unloaded-chunks")
.description("Do not allow movement into unloaded chunks")
.defaultValue(true)
.visible(() -> mode.get() == Mode.Simple)
.build()
);

public AutoWalk() {
super(Categories.Movement, "auto-walk", "Automatically walks forward.");
}
Expand All @@ -69,6 +99,11 @@ public void onDeactivate() {
@EventHandler(priority = EventPriority.HIGH)
private void onTick(TickEvent.Pre event) {
if (mode.get() == Mode.Simple) {
if (disableOnY.get() && mc.player.lastY != mc.player.getY()) {
toggle();
return;
}

switch (direction.get()) {
case Forwards -> setPressed(mc.options.forwardKey, true);
case Backwards -> setPressed(mc.options.backKey, true);
Expand All @@ -83,6 +118,37 @@ private void onTick(TickEvent.Pre event) {
}
}

private void onMovement() {
if (!disableOnInput.get()) return;
if (mc.currentScreen != null) {
GUIMove guiMove = Modules.get().get(GUIMove.class);
if (!guiMove.isActive()) return;
if (guiMove.skip()) return;
}
toggle();
}

@EventHandler
private void onKey(KeyEvent event) {
if (isMovementKey(event.key) && event.action == KeyAction.Press) onMovement();
}

@EventHandler
private void onMouseButton(MouseButtonEvent event) {
if (isMovementButton(event.button) && event.action == KeyAction.Press) onMovement();
}

@EventHandler
private void onPlayerMove(PlayerMoveEvent event) {
if (mode.get() == Mode.Simple && waitForChunks.get()) {
int chunkX = (int) ((mc.player.getX() + event.movement.x * 2) / 16);
int chunkZ = (int) ((mc.player.getZ() + event.movement.z * 2) / 16);
if (!mc.world.getChunkManager().isChunkLoaded(chunkX, chunkZ)) {
((IVec3d) event.movement).meteor$set(0, event.movement.y, 0);
}
}
}

private void unpress() {
setPressed(mc.options.forwardKey, false);
setPressed(mc.options.backKey, false);
Expand All @@ -95,6 +161,24 @@ private void setPressed(KeyBinding key, boolean pressed) {
Input.setKeyState(key, pressed);
}

private boolean isMovementKey(int key) {
return mc.options.forwardKey.matchesKey(key, 0)
|| mc.options.backKey.matchesKey(key, 0)
|| mc.options.leftKey.matchesKey(key, 0)
|| mc.options.rightKey.matchesKey(key, 0)
|| mc.options.sneakKey.matchesKey(key, 0)
|| mc.options.jumpKey.matchesKey(key, 0);
}

private boolean isMovementButton(int button) {
return mc.options.forwardKey.matchesMouse(button)
|| mc.options.backKey.matchesMouse(button)
|| mc.options.leftKey.matchesMouse(button)
|| mc.options.rightKey.matchesMouse(button)
|| mc.options.sneakKey.matchesMouse(button)
|| mc.options.jumpKey.matchesMouse(button);
}

private void createGoal() {
PathManagers.get().moveInDirection(mc.player.getYaw());
}
Expand Down