Paper/patches/server/0726-Add-API-for-item-entity-health.patch
Noah van der Aa 772fb3e385
more more more more more more more work
can't let lynx inflate his commit count too much
2023-09-22 16:59:18 +02:00

35 lines
1.1 KiB
Diff

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
== 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 ff6868ab31cec208045353c842f20ca31191bc0a..d160db37a3b7ef44b6de8fef209eeccef46c3a95 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -101,6 +101,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