@@ -262,17 +262,33 @@ public void onDeactivate() {
262
262
263
263
@ EventHandler
264
264
private void onTick (TickEvent .Pre event ) {
265
- if (!mc .player .isAlive () || PlayerUtils .getGameMode () == GameMode .SPECTATOR ) return ;
266
- if (pauseOnUse .get () && (mc .interactionManager .isBreakingBlock () || mc .player .isUsingItem ())) return ;
267
- if (onlyOnClick .get () && !mc .options .attackKey .isPressed ()) return ;
268
- if (TickRate .INSTANCE .getTimeSinceLastTick () >= 1f && pauseOnLag .get ()) return ;
269
- if (pauseOnCA .get () && Modules .get ().get (CrystalAura .class ).isActive () && Modules .get ().get (CrystalAura .class ).kaTimer > 0 ) return ;
270
-
265
+ if (!mc .player .isAlive () || PlayerUtils .getGameMode () == GameMode .SPECTATOR ) {
266
+ stopAttacking ();
267
+ return ;
268
+ }
269
+ if (pauseOnUse .get () && (mc .interactionManager .isBreakingBlock () || mc .player .isUsingItem ())) {
270
+ stopAttacking ();
271
+ return ;
272
+ }
273
+ if (onlyOnClick .get () && !mc .options .attackKey .isPressed ()) {
274
+ stopAttacking ();
275
+ return ;
276
+ }
277
+ if (TickRate .INSTANCE .getTimeSinceLastTick () >= 1f && pauseOnLag .get ()) {
278
+ stopAttacking ();
279
+ return ;
280
+ }
281
+ if (pauseOnCA .get () && Modules .get ().get (CrystalAura .class ).isActive () && Modules .get ().get (CrystalAura .class ).kaTimer > 0 ) {
282
+ stopAttacking ();
283
+ return ;
284
+ }
271
285
if (onlyOnLook .get ()) {
272
286
Entity targeted = mc .targetedEntity ;
273
287
274
- if (targeted == null ) return ;
275
- if (!entityCheck (targeted )) return ;
288
+ if (targeted == null || !entityCheck (targeted )) {
289
+ stopAttacking ();
290
+ return ;
291
+ }
276
292
277
293
targets .clear ();
278
294
targets .add (mc .targetedEntity );
@@ -282,15 +298,7 @@ private void onTick(TickEvent.Pre event) {
282
298
}
283
299
284
300
if (targets .isEmpty ()) {
285
- attacking = false ;
286
- if (wasPathing ) {
287
- PathManagers .get ().resume ();
288
- wasPathing = false ;
289
- }
290
- if (swapBack .get () && swapped ) {
291
- InvUtils .swap (previousSlot , false );
292
- swapped = false ;
293
- }
301
+ stopAttacking ();
294
302
return ;
295
303
}
296
304
@@ -319,7 +327,10 @@ private void onTick(TickEvent.Pre event) {
319
327
InvUtils .swap (weaponResult .slot (), false );
320
328
}
321
329
322
- if (!itemInHand ()) return ;
330
+ if (!itemInHand ()) {
331
+ stopAttacking ();
332
+ return ;
333
+ }
323
334
324
335
attacking = true ;
325
336
if (rotation .get () == RotationMode .Always ) Rotations .rotate (Rotations .getYaw (primary ), Rotations .getPitch (primary , Target .Body ));
@@ -338,6 +349,20 @@ private void onSendPacket(PacketEvent.Send event) {
338
349
}
339
350
}
340
351
352
+ private void stopAttacking () {
353
+ if (!attacking ) return ;
354
+
355
+ attacking = false ;
356
+ if (wasPathing ) {
357
+ PathManagers .get ().resume ();
358
+ wasPathing = false ;
359
+ }
360
+ if (swapBack .get () && swapped ) {
361
+ InvUtils .swap (previousSlot , false );
362
+ swapped = false ;
363
+ }
364
+ }
365
+
341
366
private boolean shouldShieldBreak () {
342
367
for (Entity target : targets ) {
343
368
if (target instanceof PlayerEntity player ) {
0 commit comments