aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0735-Add-API-for-item-entity-health.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0735-Add-API-for-item-entity-health.patch')
-rw-r--r--patches/server/0735-Add-API-for-item-entity-health.patch34
1 files changed, 34 insertions, 0 deletions
diff --git a/patches/server/0735-Add-API-for-item-entity-health.patch b/patches/server/0735-Add-API-for-item-entity-health.patch
new file mode 100644
index 0000000000..dd1d43a643
--- /dev/null
+++ b/patches/server/0735-Add-API-for-item-entity-health.patch
@@ -0,0 +1,34 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Sat, 28 Aug 2021 09:00:45 -0700
+Subject: [PATCH] Add API for item entity health
+
+== AT ==
+public net.minecraft.world.entity.item.ItemEntity health
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+index 953d3762292a4c15b063f9e237edf2f5c5362cb7..073643d7f83b974509cf2dd4ea41e3dd9cb90a0d 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+@@ -98,6 +98,21 @@ public class CraftItem extends CraftEntity implements Item {
+ public void setWillAge(boolean willAge) {
+ this.getHandle().age = willAge ? 0 : NO_AGE_TIME;
+ }
++
++ @Override
++ public int getHealth() {
++ return this.getHandle().health;
++ }
++
++ @Override
++ public void setHealth(int health) {
++ if (health <= 0) {
++ this.getHandle().getItem().onDestroyed(this.getHandle());
++ this.getHandle().discard();
++ } else {
++ this.getHandle().health = health;
++ }
++ }
+ // Paper End
+
+ @Override