mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Hand in PlayerItemAnimationEvent (#1650)
* Hand in PlayerItemAnimationEvent * Hand in PlayerItemAnimationEvent
This commit is contained in:
parent
24cc458659
commit
f291437ada
@ -14,12 +14,13 @@ public class PlayerItemAnimationEvent implements PlayerInstanceEvent, Cancellabl
|
||||
|
||||
private final Player player;
|
||||
private final ItemAnimationType itemAnimationType;
|
||||
|
||||
private final Player.Hand hand;
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerItemAnimationEvent(@NotNull Player player, @NotNull ItemAnimationType itemAnimationType) {
|
||||
public PlayerItemAnimationEvent(@NotNull Player player, @NotNull ItemAnimationType itemAnimationType, @NotNull Player.Hand hand) {
|
||||
this.player = player;
|
||||
this.itemAnimationType = itemAnimationType;
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,6 +32,15 @@ public class PlayerItemAnimationEvent implements PlayerInstanceEvent, Cancellabl
|
||||
return itemAnimationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hand that was used.
|
||||
*
|
||||
* @return the hand
|
||||
*/
|
||||
public @NotNull Player.Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Player getPlayer() {
|
||||
return player;
|
||||
|
@ -66,7 +66,7 @@ public class UseItemListener {
|
||||
}
|
||||
|
||||
if (!cancelAnimation && itemAnimationType != null) {
|
||||
PlayerItemAnimationEvent playerItemAnimationEvent = new PlayerItemAnimationEvent(player, itemAnimationType);
|
||||
PlayerItemAnimationEvent playerItemAnimationEvent = new PlayerItemAnimationEvent(player, itemAnimationType, hand);
|
||||
EventDispatcher.callCancellable(playerItemAnimationEvent, () -> {
|
||||
player.refreshActiveHand(true, hand == Player.Hand.OFF, riptideSpinAttack);
|
||||
player.sendPacketToViewers(player.getMetadataPacket());
|
||||
|
Loading…
Reference in New Issue
Block a user