aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0830-Add-API-for-item-entity-health.patch
blob: c475b8fda1b6e86af7b01a6b62273625a7c6676f (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 28 Aug 2021 09:00:45 -0700
Subject: [PATCH] Add API for item entity health


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
index 342345eb04d00efb58392ccf209e3c51c1064173..8d56f0ab748373e55c0166b92382c126fe8e5381 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -85,6 +85,21 @@ public class CraftItem extends CraftEntity implements Item {
      public void setWillAge(boolean willAge) {
         item.age = willAge ? 0 : NO_AGE_TIME;
      }
+
+    @Override
+    public int getHealth() {
+        return item.health;
+    }
+
+    @Override
+    public void setHealth(int health) {
+        if (health <= 0) {
+            item.getItem().onDestroyed(item);
+            item.discard();
+        } else {
+            item.health = health;
+        }
+    }
     // Paper End
 
     @Override