55
66package meteordevelopment .meteorclient .systems .modules .movement ;
77
8+ import meteordevelopment .meteorclient .events .entity .player .PlayerMoveEvent ;
89import meteordevelopment .meteorclient .events .world .TickEvent ;
10+ import meteordevelopment .meteorclient .mixininterface .IVec3d ;
911import meteordevelopment .meteorclient .pathing .NopPathManager ;
1012import meteordevelopment .meteorclient .pathing .PathManagers ;
11- import meteordevelopment .meteorclient .settings .EnumSetting ;
13+ import meteordevelopment .meteorclient .settings .* ;
1214import meteordevelopment .meteorclient .settings .Setting ;
1315import meteordevelopment .meteorclient .settings .SettingGroup ;
1416import meteordevelopment .meteorclient .systems .modules .Categories ;
@@ -51,6 +53,29 @@ public class AutoWalk extends Module {
5153 .build ()
5254 );
5355
56+ private final Setting <Boolean > disableOnInput = sgGeneral .add (new BoolSetting .Builder ()
57+ .name ("disable-on-input" )
58+ .description ("Disable module on manual movement input" )
59+ .defaultValue (false )
60+ .build ()
61+ );
62+
63+ private final Setting <Boolean > disableOnY = sgGeneral .add (new BoolSetting .Builder ()
64+ .name ("disable-on-y-change" )
65+ .description ("Disable module if player moves vertically" )
66+ .defaultValue (false )
67+ .visible (() -> mode .get () == Mode .Simple )
68+ .build ()
69+ );
70+
71+ private final Setting <Boolean > waitForChunks = sgGeneral .add (new BoolSetting .Builder ()
72+ .name ("no-unloaded-chunks" )
73+ .description ("Do not allow movement into unloaded chunks" )
74+ .defaultValue (true )
75+ .visible (() -> mode .get () == Mode .Simple )
76+ .build ()
77+ );
78+
5479 public AutoWalk () {
5580 super (Categories .Movement , "auto-walk" , "Automatically walks forward." );
5681 }
@@ -68,7 +93,17 @@ public void onDeactivate() {
6893
6994 @ EventHandler (priority = EventPriority .HIGH )
7095 private void onTick (TickEvent .Pre event ) {
96+ if (disableOnInput .get () && movementInput ()) {
97+ toggle ();
98+ return ;
99+ }
100+
71101 if (mode .get () == Mode .Simple ) {
102+ if (disableOnY .get () && mc .player .lastY != mc .player .getY ()) {
103+ toggle ();
104+ return ;
105+ }
106+
72107 switch (direction .get ()) {
73108 case Forwards -> setPressed (mc .options .forwardKey , true );
74109 case Backwards -> setPressed (mc .options .backKey , true );
@@ -83,6 +118,22 @@ private void onTick(TickEvent.Pre event) {
83118 }
84119 }
85120
121+ @ EventHandler (priority = EventPriority .HIGH )
122+ private void afterTick (TickEvent .Post event ) {
123+ unpress ();
124+ }
125+
126+ @ EventHandler
127+ private void onPlayerMove (PlayerMoveEvent event ) {
128+ if (mode .get () == Mode .Simple && waitForChunks .get ()) {
129+ int chunkX = (int ) ((mc .player .getX () + event .movement .x * 2 ) / 16 );
130+ int chunkZ = (int ) ((mc .player .getZ () + event .movement .z * 2 ) / 16 );
131+ if (!mc .world .getChunkManager ().isChunkLoaded (chunkX , chunkZ )) {
132+ ((IVec3d ) event .movement ).meteor$set (0 , event .movement .y , 0 );
133+ }
134+ }
135+ }
136+
86137 private void unpress () {
87138 setPressed (mc .options .forwardKey , false );
88139 setPressed (mc .options .backKey , false );
@@ -95,6 +146,15 @@ private void setPressed(KeyBinding key, boolean pressed) {
95146 Input .setKeyState (key , pressed );
96147 }
97148
149+ private boolean movementInput () {
150+ return mc .options .forwardKey .isPressed ()
151+ || mc .options .backKey .isPressed ()
152+ || mc .options .leftKey .isPressed ()
153+ || mc .options .rightKey .isPressed ()
154+ || mc .options .sneakKey .isPressed ()
155+ || mc .options .jumpKey .isPressed ();
156+ }
157+
98158 private void createGoal () {
99159 PathManagers .get ().moveInDirection (mc .player .getYaw ());
100160 }
0 commit comments