From a08b406af97c92c347afe10ed233ef9bcb24d10a Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 23 Oct 2018 23:04:13 -0500 Subject: [PATCH] handleCooldown --- src/main/java/baritone/bot/IBaritoneUser.java | 13 +++---------- .../baritone/bot/net/BotNetHandlerPlayClient.java | 7 +++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/bot/IBaritoneUser.java b/src/main/java/baritone/bot/IBaritoneUser.java index 119a6514b..d167a2d27 100644 --- a/src/main/java/baritone/bot/IBaritoneUser.java +++ b/src/main/java/baritone/bot/IBaritoneUser.java @@ -33,12 +33,12 @@ public interface IBaritoneUser { /** * @return The network manager that is responsible for the current connection. */ - @Nullable NetworkManager getNetworkManager(); + NetworkManager getNetworkManager(); /** * @return The locally managed entity for this bot. */ - @Nullable EntityBot getLocalEntity(); + EntityBot getLocalEntity(); /** * Returns the remote entity reported by the server that represents this bot connection. This is only @@ -46,12 +46,5 @@ public interface IBaritoneUser { * * @return The remote entity for this bot */ - @Nullable EntityOtherPlayerMP getRemoteEntity(); - - /** - * Returns the world that this entity is in. Equivalent to calling {@link #getLocalEntity().world} - * - * @return The world that this entity is in. - */ - @Nullable World getWorld(); + EntityOtherPlayerMP getRemoteEntity(); } diff --git a/src/main/java/baritone/bot/net/BotNetHandlerPlayClient.java b/src/main/java/baritone/bot/net/BotNetHandlerPlayClient.java index 0ba1015c4..b9044657b 100644 --- a/src/main/java/baritone/bot/net/BotNetHandlerPlayClient.java +++ b/src/main/java/baritone/bot/net/BotNetHandlerPlayClient.java @@ -28,6 +28,7 @@ import net.minecraft.util.IThreadListener; import net.minecraft.util.text.ITextComponent; import javax.annotation.Nonnull; +import java.util.function.Consumer; // Notes: // - All methods have been given a checkThreadAndEnqueue call, before implementing the handler, verify that it is in the actual NetHandlerPlayClient method @@ -381,6 +382,12 @@ public class BotNetHandlerPlayClient implements INetHandlerPlayClient { @Override public void handleCooldown(@Nonnull SPacketCooldown packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.client); + + if (packetIn.getTicks() == 0) { // There is no cooldown + this.user.getLocalEntity().getCooldownTracker().removeCooldown(packetIn.getItem()); + } else { + this.user.getLocalEntity().getCooldownTracker().setCooldown(packetIn.getItem(), packetIn.getTicks()); + } } @Override