aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0205-LivingEntity-Hand-Raised-Item-Use-API.patch
blob: 189a3bdc7b95a3f856afd36f308624f8e4daeb5d (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 29 Jun 2018 00:21:28 -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/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 30c6d32040decc56947d7e8a840036262e122137..0c561653f81dbc64cc78b4a27185aa3de1f9946b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -836,5 +836,30 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
     public void setShieldBlockingDelay(int delay) {
         getHandle().setShieldBlockingDelay(delay);
     }
+
+    @Override
+    public ItemStack getActiveItem() {
+        return getHandle().getUseItem().asBukkitMirror();
+    }
+
+    @Override
+    public int getItemUseRemainingTime() {
+        return getHandle().getUseItemRemainingTicks();
+    }
+
+    @Override
+    public int getHandRaisedTime() {
+        return getHandle().getTicksUsingItem();
+    }
+
+    @Override
+    public boolean isHandRaised() {
+        return getHandle().isUsingItem();
+    }
+
+    @Override
+    public org.bukkit.inventory.EquipmentSlot getHandRaised() {
+        return getHandle().getUsedItemHand() == net.minecraft.world.InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND;
+    }
     // Paper end
 }