-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LivingEntity#swingHand(EquipmentSlot) convenience method (#8456)
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 | ||
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 | ||
} |