mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
hollow-cube/fix-riptide-animation (#44)
Co-authored-by: TogAr2 <59421074+TogAr2@users.noreply.github.com>
(cherry picked from commit d901eaaed1
)
This commit is contained in:
parent
edf7b870c7
commit
ccb7a81dc9
@ -12,6 +12,7 @@ public class ItemUpdateStateEvent implements PlayerInstanceEvent, ItemEvent {
|
||||
private final Player.Hand hand;
|
||||
private final ItemStack itemStack;
|
||||
private boolean handAnimation;
|
||||
private boolean riptideSpinAttack;
|
||||
|
||||
public ItemUpdateStateEvent(@NotNull Player player, @NotNull Player.Hand hand, @NotNull ItemStack itemStack) {
|
||||
this.player = player;
|
||||
@ -24,6 +25,11 @@ public class ItemUpdateStateEvent implements PlayerInstanceEvent, ItemEvent {
|
||||
return hand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the player should have a hand animation.
|
||||
*
|
||||
* @param handAnimation whether the player should have a hand animation
|
||||
*/
|
||||
public void setHandAnimation(boolean handAnimation) {
|
||||
this.handAnimation = handAnimation;
|
||||
}
|
||||
@ -32,6 +38,19 @@ public class ItemUpdateStateEvent implements PlayerInstanceEvent, ItemEvent {
|
||||
return handAnimation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the player should have a riptide spin attack animation.
|
||||
*
|
||||
* @param riptideSpinAttack whether the player should have a riptide spin attack animation
|
||||
*/
|
||||
public void setRiptideSpinAttack(boolean riptideSpinAttack) {
|
||||
this.riptideSpinAttack = riptideSpinAttack;
|
||||
}
|
||||
|
||||
public boolean isRiptideSpinAttack() {
|
||||
return riptideSpinAttack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
|
@ -146,7 +146,8 @@ public final class PlayerDiggingListener {
|
||||
player.refreshActiveHand(true, false, false);
|
||||
} else {
|
||||
final boolean isOffHand = itemUpdateStateEvent.getHand() == Player.Hand.OFF;
|
||||
player.refreshActiveHand(itemUpdateStateEvent.hasHandAnimation(), isOffHand, false);
|
||||
player.refreshActiveHand(itemUpdateStateEvent.hasHandAnimation(),
|
||||
isOffHand, itemUpdateStateEvent.isRiptideSpinAttack());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ public class UseItemListener {
|
||||
}
|
||||
|
||||
PlayerItemAnimationEvent.ItemAnimationType itemAnimationType = null;
|
||||
boolean riptideSpinAttack = false;
|
||||
|
||||
boolean cancelAnimation = false;
|
||||
|
||||
@ -68,7 +67,7 @@ public class UseItemListener {
|
||||
if (!cancelAnimation && itemAnimationType != null) {
|
||||
PlayerItemAnimationEvent playerItemAnimationEvent = new PlayerItemAnimationEvent(player, itemAnimationType, hand);
|
||||
EventDispatcher.callCancellable(playerItemAnimationEvent, () -> {
|
||||
player.refreshActiveHand(true, hand == Player.Hand.OFF, riptideSpinAttack);
|
||||
player.refreshActiveHand(true, hand == Player.Hand.OFF, false);
|
||||
player.sendPacketToViewers(player.getMetadataPacket());
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user