PaperMC/Spigot-Server-Patches/0277-LivingEntity-Hand-Raised-Item-Use-API.patch

67 lines
2.3 KiB
Diff
Raw Normal View History

From b38b8d9b970ba9669dff79d66e7e6ab750b7394b 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/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index a8f58a13fe..c051200da8 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -106,7 +106,7 @@ public abstract class EntityLiving extends Entity {
private float bI;
private int bJ;
private float bK;
- protected ItemStack activeItem;
+ public ItemStack activeItem; // Paper - public
protected int bu;
protected int bv;
private BlockPosition bL;
@@ -2692,10 +2692,12 @@ public abstract class EntityLiving extends Entity {
return this.activeItem;
}
+ public int getItemUseRemainingTime() { return cX(); } // Paper - OBFHELPER
public int cX() {
return this.bu;
}
+ public int getHandRaisedTime() { return cY(); } // Paper - OBFHELPER
public int cY() {
return this.isHandRaised() ? this.activeItem.k() - this.cX() : 0;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index a09cd02403..0860f2334d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
2018-08-02 04:49:47 +02:00
@@ -543,5 +543,25 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setShieldBlockingDelay(int delay) {
getHandle().setShieldBlockingDelay(delay);
}
+
+ @Override
+ public ItemStack getActiveItem() {
+ return getHandle().activeItem.asBukkitMirror();
+ }
+
+ @Override
+ public int getItemUseRemainingTime() {
+ return getHandle().getItemUseRemainingTime();
+ }
+
+ @Override
+ public int getHandRaisedTime() {
+ return getHandle().getHandRaisedTime();
+ }
+
+ @Override
+ public boolean isHandRaised() {
+ return getHandle().isHandRaised();
+ }
// Paper end
}
--
2.19.0