Cleanup LivingEntity Hand Raised/Item Use API (#7995)

This commit is contained in:
Owen 2022-06-24 04:04:02 -04:00 committed by GitHub
parent bdb6816960
commit 5593f4edd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 31 deletions

View file

@ -5,29 +5,35 @@ Subject: [PATCH] LivingEntity Hand Raised/Item Use API
How long an entity has raised hands to charge an attack or use an item
diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java
index bd9222b9b5e7ec1f3aebe37838775f345e868150..34c2ae10e2a230ef88a756cf2024edcda2429fbf 100644
--- a/src/main/java/org/bukkit/entity/HumanEntity.java
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java
@@ -307,7 +307,9 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder
*
* @return the item being used by the player, or null if they are not using
* an item
+ * @deprecated Deprecated in favor of {@link LivingEntity#getActiveItem()}
*/
+ @Deprecated // Paper
@Nullable
public ItemStack getItemInUse();
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 588ad09a764236cf858a4e6689cf4ee5246e6f08..6d8d96976bcef4e176453fede81a529478f11234 100644
index 588ad09a764236cf858a4e6689cf4ee5246e6f08..1dd9f7ac1f26c253b8181519aa1873784bc54a07 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -12,6 +12,7 @@ import org.bukkit.attribute.Attributable;
import org.bukkit.block.Block;
import org.bukkit.entity.memory.MemoryKey;
import org.bukkit.inventory.EntityEquipment;
+import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
@@ -649,5 +650,42 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -649,5 +649,42 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param delay Delay in ticks
*/
void setShieldBlockingDelay(int delay);
+
+ /**
+ * Get's the item being actively "used" or consumed.
+ * @return The item. Will be null if no active item.
+ * @return The item
+ */
+ @Nullable
+ ItemStack getActiveItem();
+ @NotNull
+ org.bukkit.inventory.ItemStack getActiveItem();
+
+ /**
+ * Get's remaining time a player needs to keep hands raised with an item to finish using it.