handleCooldown

This commit is contained in:
Brady
2018-10-23 23:04:13 -05:00
parent 1afd367e53
commit a08b406af9
2 changed files with 10 additions and 10 deletions
+3 -10
View File
@@ -33,12 +33,12 @@ public interface IBaritoneUser {
/** /**
* @return The network manager that is responsible for the current connection. * @return The network manager that is responsible for the current connection.
*/ */
@Nullable NetworkManager getNetworkManager(); NetworkManager getNetworkManager();
/** /**
* @return The locally managed entity for this bot. * @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 * 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 * @return The remote entity for this bot
*/ */
@Nullable EntityOtherPlayerMP getRemoteEntity(); 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();
} }
@@ -28,6 +28,7 @@ import net.minecraft.util.IThreadListener;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.function.Consumer;
// Notes: // Notes:
// - All methods have been given a checkThreadAndEnqueue call, before implementing the handler, verify that it is in the actual NetHandlerPlayClient method // - 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 @Override
public void handleCooldown(@Nonnull SPacketCooldown packetIn) { public void handleCooldown(@Nonnull SPacketCooldown packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.client); 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 @Override