aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0117-LivingEntity-Hand-Raised-Item-Use-API.patch
blob: 01ca874a1f18f6cc1254c239396c2899395f8dcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 29 Jun 2018 00:19:19 -0400
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 b3aa3dc6aa5afbc36cc86741b4cba56f463c2234..9e012c3c0671e5d0e55c243fdb4e14057038c153 100644
--- a/src/main/java/org/bukkit/entity/HumanEntity.java
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java
@@ -328,7 +328,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 dd5c5e0ec342cea1bf9efbd0aa28ae0e0ed2f6b9..fd98b9de7714e2082e521f29dc162003e3d39ee2 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -823,5 +823,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
+     */
+    @NotNull
+    org.bukkit.inventory.ItemStack getActiveItem();
+
+    /**
+     * Get's remaining time a player needs to keep hands raised with an item to finish using it.
+     * @return Remaining ticks to use the item
+     */
+    int getItemUseRemainingTime();
+
+    /**
+     * Get how long the players hands have been raised (Charging Bow attack, using a potion, etc)
+     *
+     * @return Get how long the players hands have been raised (Charging Bow attack, using a potion, etc)
+     */
+    int getHandRaisedTime();
+
+    /**
+     * Whether or not this entity is using or charging an attack (Bow pulled back, drinking potion, eating food)
+     *
+     * @return Whether or not this entity is using or charging an attack (Bow pulled back, drinking potion, eating food)
+     */
+    boolean isHandRaised();
+
+    /**
+     * Gets the hand raised by this living entity. Will be either
+     * {@link org.bukkit.inventory.EquipmentSlot#HAND} or
+     * {@link org.bukkit.inventory.EquipmentSlot#OFF_HAND}.
+     *
+     * @return the hand raised
+     */
+    @NotNull
+    org.bukkit.inventory.EquipmentSlot getHandRaised();
     // Paper end
 }