@@ -50,7 +50,8 @@ public AttackArua() {
5050 public final FlagRef doNotAttackWhenEat =
5151 flagBuilder (attBot .add ("stop-attack-when-eat" )).build ();
5252
53- public final FlagRef doNotAttackWhenSpear = flagBuilder (attBot .add ("stop-attack-when-spear" )).build ();
53+ public final FlagRef doNotAttackWhenSpear =
54+ flagBuilder (attBot .add ("stop-attack-when-spear" )).build ();
5455
5556 @ Override
5657 public void registerAll () {
@@ -60,6 +61,22 @@ public void registerAll() {
6061
6162 private int interval ;
6263
64+ public boolean checkEating () {
65+ return doNotAttackWhenEat .get ()
66+ && mc .player .isUsingItem ()
67+ && VItem .getInstance ().isEatable (mc .player .getActiveItem ());
68+ }
69+
70+ public boolean checkSpear () {
71+ return doNotAttackWhenSpear .get ()
72+ && mc .player .isUsingItem ()
73+ && VItem .getInstance ().isSpear (mc .player .getActiveItem ());
74+ }
75+
76+ public boolean checkUsing () {
77+ return checkEating () || checkSpear ();
78+ }
79+
6380 public void onTick (Event <ClientPlayerEntity > tickEvent ) {
6481 if (mc .player == null ) return ;
6582 if (enable .get ()) {
@@ -69,18 +86,11 @@ public void onTick(Event<ClientPlayerEntity> tickEvent) {
6986 interval += 1 ;
7087 int custom = customRate .get ();
7188 if (custom <= interval ) {
72- if (doNotAttackWhenEat .get ()
73- && mc .player .isUsingItem ()
74- && VItem .getInstance ().isEatable (mc .player .getActiveItem ())) {
75- return ;
76- }
77- if (doNotAttackWhenSpear .get () && mc .player .isUsingItem () && VItem .getInstance ().isSpear (mc .player .getActiveItem ())) {
78- return ;
79- }
89+
8090 if (attack .legalMode .get ()
8191 || ((holdingWeapon && cooldownWeapon .get ()) || (!holdingWeapon && cooldownHand .get ()))) {
8292 // do not attack because of legal mode
83-
93+ if ( checkUsing ()) return ;
8494 if (mc .player .getAttackCooldownProgress (0.5F ) > 0.98 ) {
8595 // ready for attack
8696 // force attack
0 commit comments