aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0367-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/api/0367-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch')
-rw-r--r--patches/api/0367-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch35
1 files changed, 35 insertions, 0 deletions
diff --git a/patches/api/0367-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch b/patches/api/0367-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
new file mode 100644
index 0000000000..2a6826e5c3
--- /dev/null
+++ b/patches/api/0367-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
@@ -0,0 +1,35 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: SoSeDiK <[email protected]>
+Date: Tue, 11 Oct 2022 22:35:56 +0300
+Subject: [PATCH] Add LivingEntity#swingHand(EquipmentSlot) convenience method
+
+
+diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
+index 0c7d96bc296b56dc9ff0ada89bb4d715716f8adc..fb62933d589ccbe4181a7b9633bb742ae35f68dd 100644
+--- a/src/main/java/org/bukkit/entity/LivingEntity.java
++++ b/src/main/java/org/bukkit/entity/LivingEntity.java
+@@ -1331,4 +1331,24 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+ @Deprecated
+ void setHurtDirection(float hurtDirection);
+ // Paper end - hurt direction API
++
++ // Paper start - swing hand API
++ /**
++ * Makes this entity swing their hand.
++ *
++ * <p>This method does nothing if this entity does not
++ * have an animation for swinging their hand.
++ *
++ * @param hand hand to be swung, either {@link org.bukkit.inventory.EquipmentSlot#HAND} or {@link org.bukkit.inventory.EquipmentSlot#OFF_HAND}
++ * @throws IllegalArgumentException if invalid hand is passed
++ */
++ default void swingHand(@NotNull org.bukkit.inventory.EquipmentSlot hand) {
++ com.google.common.base.Preconditions.checkArgument(hand != null && hand.isHand(), String.format("Expected a valid hand, got \"%s\" instead!", hand));
++ if (hand == org.bukkit.inventory.EquipmentSlot.HAND) {
++ this.swingMainHand();
++ } else {
++ this.swingOffHand();
++ }
++ }
++ // Paper end - swing hand API
+ }