diff options
author | SoSeDiK <[email protected]> | 2022-10-16 14:49:56 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-16 13:49:56 +0200 |
commit | 236a29623c979a6c97e1029fe8d1448d42f6d226 (patch) | |
tree | 0d296db996e11326f196ae2791bca28d23a5eaea | |
parent | ec00f991a459c1f747648d18da84263a81efda98 (diff) | |
download | Paper-236a29623c979a6c97e1029fe8d1448d42f6d226.tar.gz Paper-236a29623c979a6c97e1029fe8d1448d42f6d226.zip |
Add LivingEntity#swingHand(EquipmentSlot) convenience method (#8456)
-rw-r--r-- | patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch b/patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch new file mode 100644 index 0000000000..b153283237 --- /dev/null +++ b/patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch @@ -0,0 +1,34 @@ +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 4af5e8d0cba6555f7615e4e809d9aff221c0dc4d..319e4571aca24d1e3f6c85b7435d65c0e77a5245 100644 +--- a/src/main/java/org/bukkit/entity/LivingEntity.java ++++ b/src/main/java/org/bukkit/entity/LivingEntity.java +@@ -985,5 +985,23 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource + * @param hurtDirection hurt direction + */ + void setHurtDirection(float hurtDirection); ++ ++ /** ++ * 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 == org.bukkit.inventory.EquipmentSlot.HAND || hand == org.bukkit.inventory.EquipmentSlot.OFF_HAND, String.format("Expected a valid hand, got \"%s\" instead!", hand)); ++ if (hand == org.bukkit.inventory.EquipmentSlot.HAND) { ++ this.swingMainHand(); ++ } else { ++ this.swingOffHand(); ++ } ++ } + // Paper end + } |