66import com .zenith .feature .player .ClickTarget ;
77import com .zenith .feature .player .Input ;
88import com .zenith .feature .player .InputRequest ;
9- import com .zenith .mc .block .Direction ;
109import com .zenith .mc .item .ItemData ;
1110import com .zenith .mc .item .ItemRegistry ;
1211import com .zenith .util .RequestFuture ;
1312import net .kyori .adventure .text .Component ;
1413import net .kyori .adventure .text .TranslatableComponent ;
1514import org .geysermc .mcprotocollib .protocol .data .game .entity .Effect ;
1615import org .geysermc .mcprotocollib .protocol .data .game .entity .player .GameMode ;
17- import org .geysermc .mcprotocollib .protocol .data .game .entity .player .PlayerAction ;
1816import org .geysermc .mcprotocollib .protocol .data .game .item .ItemStack ;
19- import org .geysermc .mcprotocollib .protocol .packet .ingame .serverbound .player .ServerboundPlayerActionPacket ;
2017
2118import java .util .List ;
2219import java .util .Objects ;
@@ -68,14 +65,12 @@ public void handleClientTick(final ClientBotTick e) {
6865 lastRaidActive = System .nanoTime ();
6966 }
7067 if (CACHE .getPlayerCache ().getThePlayer ().isAlive ()
71- && (CONFIG .client .extra .autoOmen .whileRaidActive || (TimeUnit .NANOSECONDS .toMillis (System .nanoTime () - lastRaidActive ) > CONFIG .client .extra .autoOmen .raidCooldownMs ))
72- && (CONFIG .client .extra .autoOmen .whileOmenActive || (TimeUnit .NANOSECONDS .toMillis (System .nanoTime () - lastHadOmen ) > CONFIG .client .extra .autoOmen .omenCooldownMs ))
7368 && CACHE .getPlayerCache ().getGameMode () != GameMode .CREATIVE
7469 && CACHE .getPlayerCache ().getGameMode () != GameMode .SPECTATOR
7570 ) {
7671 if (delay > 0 ) {
7772 delay --;
78- if (isEating || ! swapFuture . isDone () ) {
73+ if (isEating ) {
7974 INPUTS .submit (InputRequest .noInput (this , getPriority ()));
8075 INVENTORY .submit (InventoryActionRequest .noAction (this , getPriority ()));
8176 }
@@ -86,49 +81,38 @@ public void handleClientTick(final ClientBotTick e) {
8681 INPUTS .submit (InputRequest .noInput (this , getPriority ()));
8782 return ;
8883 }
84+ var raidActiveCondition = CONFIG .client .extra .autoOmen .whileRaidActive || TimeUnit .NANOSECONDS .toMillis (System .nanoTime () - lastRaidActive ) > CONFIG .client .extra .autoOmen .raidCooldownMs ;
85+ var omenActiveCondition = CONFIG .client .extra .autoOmen .whileOmenActive || TimeUnit .NANOSECONDS .toMillis (System .nanoTime () - lastHadOmen ) > CONFIG .client .extra .autoOmen .omenCooldownMs ;
86+ if (!raidActiveCondition || !omenActiveCondition ) {
87+ return ;
88+ }
8989 var invActionResult = doInventoryActionsV2 ();
9090 switch (invActionResult .state ()) {
9191 case ITEM_IN_HAND -> {
9292 startEating ();
9393 INVENTORY .submit (InventoryActionRequest .noAction (this , getPriority ()));
94+ delay = invActionResult .expectedDelay ();
9495 }
9596 case NO_ITEM -> {}
9697 case SWAPPING -> {
9798 swapFuture = invActionResult .inventoryActionFuture ();
9899 }
99100 default -> throw new IllegalStateException ("Unexpected action state: " + invActionResult .state ());
100101 }
101- delay = invActionResult .expectedDelay ();
102102 } else {
103- if (isEating ) {
104- if (delay > 0 ) { // we got interrupted during drinking
105- // todo: have bot automatically cancel eats if not confirmed every tick?
106- sendClientPacketAsync (new ServerboundPlayerActionPacket (
107- PlayerAction .RELEASE_USE_ITEM ,
108- 0 , 0 , 0 ,
109- Direction .DOWN .mcpl (),
110- CACHE .getPlayerCache ().getSeqId ().incrementAndGet ()
111- ));
112- debug ("Got interrupted during omen drink" );
113- delay = 0 ;
114- } else {
115- delay = 20 ;
116- debug ("Omen drink completed" );
117- }
118- } else {
119- delay = 0 ;
120- }
121103 isEating = false ;
104+ delay = 0 ;
122105 }
123106 }
124107
125108 public void startEating () {
109+ if (!isItemEquipped ()) return ;
126110 var hand = getHand ();
127- if (hand == null ) return ;
128111 INPUTS .submit (InputRequest .builder ()
129112 .owner (this )
130113 .input (Input .builder ()
131114 .rightClick (true )
115+ .hand (hand )
132116 .clickTarget (ClickTarget .None .INSTANCE )
133117 .clickRequiresRotation (false )
134118 .build ())
0 commit comments