2022-10-16 13:49:56 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: SoSeDiK <mrsosedik@gmail.com>
|
|
|
|
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
|
2024-04-23 19:02:08 +02:00
|
|
|
index b5551eed2e9090dcbbe97cae25a0c0545285c64f..1041af2b645e15d8a94fe388cb88f1a8adde16f0 100644
|
2022-10-16 13:49:56 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
2024-04-23 19:02:08 +02:00
|
|
|
@@ -1331,4 +1331,24 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
2023-03-14 23:13:41 +01:00
|
|
|
@Deprecated
|
2022-10-16 13:49:56 +02:00
|
|
|
void setHurtDirection(float hurtDirection);
|
2024-04-06 21:53:39 +02:00
|
|
|
// Paper end - hurt direction API
|
2022-10-16 13:49:56 +02:00
|
|
|
+
|
2024-04-06 21:53:39 +02:00
|
|
|
+ // Paper start - swing hand API
|
2022-10-16 13:49:56 +02:00
|
|
|
+ /**
|
|
|
|
+ * 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) {
|
2022-10-23 01:50:12 +02:00
|
|
|
+ com.google.common.base.Preconditions.checkArgument(hand != null && hand.isHand(), String.format("Expected a valid hand, got \"%s\" instead!", hand));
|
2022-10-16 13:49:56 +02:00
|
|
|
+ if (hand == org.bukkit.inventory.EquipmentSlot.HAND) {
|
|
|
|
+ this.swingMainHand();
|
|
|
|
+ } else {
|
|
|
|
+ this.swingOffHand();
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-04-06 21:53:39 +02:00
|
|
|
+ // Paper end - swing hand API
|
2022-10-16 13:49:56 +02:00
|
|
|
}
|