55
66package meteordevelopment .meteorclient .systems .modules .movement ;
77
8+ import meteordevelopment .meteorclient .events .entity .player .PlayerMoveEvent ;
9+ import meteordevelopment .meteorclient .events .meteor .KeyEvent ;
10+ import meteordevelopment .meteorclient .events .meteor .MouseButtonEvent ;
811import meteordevelopment .meteorclient .events .world .TickEvent ;
12+ import meteordevelopment .meteorclient .mixininterface .IVec3d ;
913import meteordevelopment .meteorclient .pathing .NopPathManager ;
1014import meteordevelopment .meteorclient .pathing .PathManagers ;
11- import meteordevelopment .meteorclient .settings .EnumSetting ;
15+ import meteordevelopment .meteorclient .settings .* ;
1216import meteordevelopment .meteorclient .settings .Setting ;
1317import meteordevelopment .meteorclient .settings .SettingGroup ;
1418import meteordevelopment .meteorclient .systems .modules .Categories ;
1519import meteordevelopment .meteorclient .systems .modules .Module ;
20+ import meteordevelopment .meteorclient .systems .modules .Modules ;
21+ import meteordevelopment .meteorclient .systems .modules .movement .GUIMove ;
1622import meteordevelopment .meteorclient .utils .Utils ;
1723import meteordevelopment .meteorclient .utils .misc .input .Input ;
24+ import meteordevelopment .meteorclient .utils .misc .input .KeyAction ;
1825import meteordevelopment .orbit .EventHandler ;
1926import meteordevelopment .orbit .EventPriority ;
2027import net .minecraft .client .option .KeyBinding ;
@@ -51,6 +58,29 @@ public class AutoWalk extends Module {
5158 .build ()
5259 );
5360
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+
5484 public AutoWalk () {
5585 super (Categories .Movement , "auto-walk" , "Automatically walks forward." );
5686 }
@@ -69,6 +99,11 @@ public void onDeactivate() {
6999 @ EventHandler (priority = EventPriority .HIGH )
70100 private void onTick (TickEvent .Pre event ) {
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,37 @@ private void onTick(TickEvent.Pre event) {
83118 }
84119 }
85120
121+ private void onMovement () {
122+ if (!disableOnInput .get ()) return ;
123+ if (mc .currentScreen != 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 (KeyEvent event ) {
133+ if (isMovementKey (event .key ) && event .action == KeyAction .Press ) onMovement ();
134+ }
135+
136+ @ EventHandler
137+ private void onMouseButton (MouseButtonEvent event ) {
138+ if (isMovementButton (event .button ) && 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 .world .getChunkManager ().isChunkLoaded (chunkX , chunkZ )) {
147+ ((IVec3d ) event .movement ).meteor$set (0 , event .movement .y , 0 );
148+ }
149+ }
150+ }
151+
86152 private void unpress () {
87153 setPressed (mc .options .forwardKey , false );
88154 setPressed (mc .options .backKey , false );
@@ -95,6 +161,24 @@ private void setPressed(KeyBinding key, boolean pressed) {
95161 Input .setKeyState (key , pressed );
96162 }
97163
164+ private boolean isMovementKey (int key ) {
165+ return mc .options .forwardKey .matchesKey (key , 0 )
166+ || mc .options .backKey .matchesKey (key , 0 )
167+ || mc .options .leftKey .matchesKey (key , 0 )
168+ || mc .options .rightKey .matchesKey (key , 0 )
169+ || mc .options .sneakKey .matchesKey (key , 0 )
170+ || mc .options .jumpKey .matchesKey (key , 0 );
171+ }
172+
173+ private boolean isMovementButton (int button ) {
174+ return mc .options .forwardKey .matchesMouse (button )
175+ || mc .options .backKey .matchesMouse (button )
176+ || mc .options .leftKey .matchesMouse (button )
177+ || mc .options .rightKey .matchesMouse (button )
178+ || mc .options .sneakKey .matchesMouse (button )
179+ || mc .options .jumpKey .matchesMouse (button );
180+ }
181+
98182 private void createGoal () {
99183 PathManagers .get ().moveInDirection (mc .player .getYaw ());
100184 }
0 commit comments