mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 01:47:54 +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 Player player;
|
||||||
private final ItemAnimationType itemAnimationType;
|
private final ItemAnimationType itemAnimationType;
|
||||||
|
private final Player.Hand hand;
|
||||||
private boolean cancelled;
|
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.player = player;
|
||||||
this.itemAnimationType = itemAnimationType;
|
this.itemAnimationType = itemAnimationType;
|
||||||
|
this.hand = hand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +32,15 @@ public class PlayerItemAnimationEvent implements PlayerInstanceEvent, Cancellabl
|
|||||||
return itemAnimationType;
|
return itemAnimationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the hand that was used.
|
||||||
|
*
|
||||||
|
* @return the hand
|
||||||
|
*/
|
||||||
|
public @NotNull Player.Hand getHand() {
|
||||||
|
return hand;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Player getPlayer() {
|
public @NotNull Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
|
@ -66,7 +66,7 @@ public class UseItemListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!cancelAnimation && itemAnimationType != null) {
|
if (!cancelAnimation && itemAnimationType != null) {
|
||||||
PlayerItemAnimationEvent playerItemAnimationEvent = new PlayerItemAnimationEvent(player, itemAnimationType);
|
PlayerItemAnimationEvent playerItemAnimationEvent = new PlayerItemAnimationEvent(player, itemAnimationType, hand);
|
||||||
EventDispatcher.callCancellable(playerItemAnimationEvent, () -> {
|
EventDispatcher.callCancellable(playerItemAnimationEvent, () -> {
|
||||||
player.refreshActiveHand(true, hand == Player.Hand.OFF, riptideSpinAttack);
|
player.refreshActiveHand(true, hand == Player.Hand.OFF, riptideSpinAttack);
|
||||||
player.sendPacketToViewers(player.getMetadataPacket());
|
player.sendPacketToViewers(player.getMetadataPacket());
|
||||||
|
Loading…
Reference in New Issue
Block a user