Paper/patches/server/0772-Add-API-for-item-entity-health.patch
Nassim Jahnke 20503beee5
Remove guardian beam render issue workaround
Messing with game time sent to the client isn't worth the trouble whenever it may be used by the client now and in the future for such a small issue. Mojang, plz fix
2022-12-15 14:19:09 +01: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 1d90219c3a0e86786a9497d4c078c2d4077ab6cd..fea44ba6a6584b4a510af6a58cab07eecec6b68b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -102,6 +102,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