Paper/Spigot-Server-Patches/0318-LivingEntity-Hand-Raised-Item-Use-API.patch
Aikar 18c3716c49
Current Chunk for Entity and Block Entities, counts by entity type
This enables us a fast reference to the entities current chunk instead
of having to look it up by hashmap lookups.

We also store counts by type to further enable other performance optimizations in later patches.
2018-07-04 03:58:56 -04:00

63 lines
2.1 KiB
Diff

From 14736699b8f04a3ba9fe7e1ded6ab047a0e9cb4d 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 156bf8ee0..14637be49 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2466,14 +2466,17 @@ public abstract class EntityLiving extends Entity {
}
+ public ItemStack getActiveItem() { return cJ(); } // Paper - OBFHELPER
public ItemStack cJ() {
return this.activeItem;
}
+ public int getItemUseRemainingTime() { return cK(); } // Paper - OBFHELPER
public int cK() {
return this.bp;
}
+ public int getHandRaisedTime() { return cL(); } // Paper - OBFHELPER
public int cL() {
return this.isHandRaised() ? this.activeItem.m() - this.cK() : 0;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 14fb474f7..9c750efc7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -525,5 +525,25 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setShieldBlockingDelay(int delay) {
getHandle().setShieldBlockingDelay(delay);
}
+
+ @Override
+ public ItemStack getActiveItem() {
+ return getHandle().getActiveItem().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.18.0