diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java index 4326182586..3a779984ad 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java @@ -17,6 +17,8 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; +import static ac.grim.grimac.utils.inventory.Inventory.HOTBAR_OFFSET; + public class PacketPlayerAttack extends PacketListenerAbstract { public PacketPlayerAttack() { @@ -45,9 +47,11 @@ public void onPacketReceive(PacketReceiveEvent event) { PacketEntity entity = player.compensatedEntities.getEntity(interact.getEntityId()); // You don't get a release use item with block hitting with a sword? - if (heldItem != null && player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) { - if (heldItem.getType().hasAttribute(ItemTypes.ItemAttribute.SWORD)) + if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && player.packetStateData.isSlowedByUsingItem()) { + ItemStack item = player.getInventory().inventory.getPlayerInventoryItem(player.packetStateData.getSlowedByUsingItemSlot() + HOTBAR_OFFSET); + if (item.getType().hasAttribute(ItemTypes.ItemAttribute.SWORD)) { player.packetStateData.setSlowedByUsingItem(false); + } } if (entity != null && (!(entity.isLivingEntity()) || entity.getType() == EntityTypes.PLAYER)) { diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerDigging.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerDigging.java index 6920db1f7a..e83895eb79 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerDigging.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerDigging.java @@ -171,7 +171,7 @@ public void onPacketReceive(PacketReceiveEvent event) { if (player == null) return; if (!player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate) { - if (player.packetStateData.isSlowedByUsingItem() && player.packetStateData.slowedByUsingItemSlot != player.packetStateData.lastSlotSelected) { + if (player.packetStateData.isSlowedByUsingItem() && player.packetStateData.getSlowedByUsingItemSlot() != player.packetStateData.lastSlotSelected) { player.packetStateData.setSlowedByUsingItem(false); player.checkManager.getPostPredictionCheck(NoSlowA.class).didSlotChangeLastTick = true; } diff --git a/src/main/java/ac/grim/grimac/utils/data/PacketStateData.java b/src/main/java/ac/grim/grimac/utils/data/PacketStateData.java index e59d7295ac..2886e38af9 100644 --- a/src/main/java/ac/grim/grimac/utils/data/PacketStateData.java +++ b/src/main/java/ac/grim/grimac/utils/data/PacketStateData.java @@ -17,7 +17,9 @@ public class PacketStateData { public boolean tryingToRiptide = false; @Getter private boolean slowedByUsingItem; - public int slowedByUsingItemTransaction, slowedByUsingItemSlot = Integer.MIN_VALUE; + @Getter + private int slowedByUsingItemSlot = Integer.MIN_VALUE; + public int slowedByUsingItemTransaction = Integer.MIN_VALUE; public boolean receivedSteerVehicle = false; // This works on 1.8 only public boolean didLastLastMovementIncludePosition = false;