3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 19:40:07 +01:00
Paper/Spigot-Server-Patches/0315-LivingEntity-Hand-Raised-Item-Use-API.patch

63 Zeilen
2.1 KiB
Diff

From 9f02fc6f591f197d9531a73fc2148cac720c6fef 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