Hand in PlayerItemAnimationEvent (#1650)

* Hand in PlayerItemAnimationEvent

* Hand in PlayerItemAnimationEvent
This commit is contained in:
HEROOSTECH 2023-01-04 01:11:17 +01:00 committed by GitHub
parent 24cc458659
commit f291437ada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -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;

View File

@ -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());