5
5
6
6
package meteordevelopment .meteorclient .systems .modules .movement ;
7
7
8
+ import meteordevelopment .meteorclient .events .entity .player .PlayerMoveEvent ;
9
+ import meteordevelopment .meteorclient .events .meteor .KeyEvent ;
10
+ import meteordevelopment .meteorclient .events .meteor .MouseButtonEvent ;
8
11
import meteordevelopment .meteorclient .events .world .TickEvent ;
12
+ import meteordevelopment .meteorclient .mixininterface .IVec3d ;
9
13
import meteordevelopment .meteorclient .pathing .NopPathManager ;
10
14
import meteordevelopment .meteorclient .pathing .PathManagers ;
11
- import meteordevelopment .meteorclient .settings .EnumSetting ;
15
+ import meteordevelopment .meteorclient .settings .* ;
12
16
import meteordevelopment .meteorclient .settings .Setting ;
13
17
import meteordevelopment .meteorclient .settings .SettingGroup ;
14
18
import meteordevelopment .meteorclient .systems .modules .Categories ;
15
19
import meteordevelopment .meteorclient .systems .modules .Module ;
20
+ import meteordevelopment .meteorclient .systems .modules .Modules ;
21
+ import meteordevelopment .meteorclient .systems .modules .movement .GUIMove ;
16
22
import meteordevelopment .meteorclient .utils .Utils ;
17
23
import meteordevelopment .meteorclient .utils .misc .input .Input ;
24
+ import meteordevelopment .meteorclient .utils .misc .input .KeyAction ;
18
25
import meteordevelopment .orbit .EventHandler ;
19
26
import meteordevelopment .orbit .EventPriority ;
20
27
import net .minecraft .client .option .KeyBinding ;
@@ -51,6 +58,29 @@ public class AutoWalk extends Module {
51
58
.build ()
52
59
);
53
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
+
54
84
public AutoWalk () {
55
85
super (Categories .Movement , "auto-walk" , "Automatically walks forward." );
56
86
}
@@ -69,6 +99,11 @@ public void onDeactivate() {
69
99
@ EventHandler (priority = EventPriority .HIGH )
70
100
private void onTick (TickEvent .Pre event ) {
71
101
if (mode .get () == Mode .Simple ) {
102
+ if (disableOnY .get () && mc .player .lastY != mc .player .getY ()) {
103
+ toggle ();
104
+ return ;
105
+ }
106
+
72
107
switch (direction .get ()) {
73
108
case Forwards -> setPressed (mc .options .forwardKey , true );
74
109
case Backwards -> setPressed (mc .options .backKey , true );
@@ -83,6 +118,37 @@ private void onTick(TickEvent.Pre event) {
83
118
}
84
119
}
85
120
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
+
86
152
private void unpress () {
87
153
setPressed (mc .options .forwardKey , false );
88
154
setPressed (mc .options .backKey , false );
@@ -95,6 +161,24 @@ private void setPressed(KeyBinding key, boolean pressed) {
95
161
Input .setKeyState (key , pressed );
96
162
}
97
163
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
+
98
182
private void createGoal () {
99
183
PathManagers .get ().moveInDirection (mc .player .getYaw ());
100
184
}
0 commit comments