From ed064c42bebc854399f0e98a1a33d44813ae5d0e Mon Sep 17 00:00:00 2001 From: Bloepiloepi <59421074+Bloepiloepi@users.noreply.github.com> Date: Tue, 10 Aug 2021 01:20:01 +0200 Subject: [PATCH] Use active hand when updating item state --- .../server/listener/PlayerDiggingListener.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/minestom/server/listener/PlayerDiggingListener.java b/src/main/java/net/minestom/server/listener/PlayerDiggingListener.java index a92f6f59a..110712475 100644 --- a/src/main/java/net/minestom/server/listener/PlayerDiggingListener.java +++ b/src/main/java/net/minestom/server/listener/PlayerDiggingListener.java @@ -2,6 +2,7 @@ package net.minestom.server.listener; import net.minestom.server.entity.GameMode; import net.minestom.server.entity.Player; +import net.minestom.server.entity.metadata.PlayerMeta; import net.minestom.server.event.EventDispatcher; import net.minestom.server.event.item.ItemUpdateStateEvent; import net.minestom.server.event.player.PlayerStartDiggingEvent; @@ -136,14 +137,9 @@ public class PlayerDiggingListener { } } else if (status == ClientPlayerDiggingPacket.Status.UPDATE_ITEM_STATE) { - Player.Hand hand = null; - if (player.isEating()) { - hand = player.getEatingHand(); - } else if (player.getItemInHand(Player.Hand.OFF).getMaterial().hasState()) { - hand = Player.Hand.OFF; - } else if (player.getItemInHand(Player.Hand.MAIN).getMaterial().hasState()) { - hand = Player.Hand.MAIN; - } + PlayerMeta meta = player.getEntityMeta(); + if (!meta.isHandActive()) return; + Player.Hand hand = meta.getActiveHand(); player.refreshEating(null); player.triggerStatus((byte) 9);