2021-12-22 08:07:15 +01:00
|
|
|
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
|
|
|
|
|
2022-11-20 00:53:20 +01:00
|
|
|
== AT ==
|
|
|
|
public net.minecraft.world.entity.item.ItemEntity health
|
2021-12-22 08:07:15 +01:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
2024-01-19 22:13:42 +01:00
|
|
|
index 4a15c3786edbfeae3367c0b20fb6aee11d62aea6..cbfd4cf1d7d32757cf124d1aaa4b83d8a155868f 100644
|
2021-12-22 08:07:15 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
2023-10-22 21:12:00 +02:00
|
|
|
@@ -98,6 +98,21 @@ public class CraftItem extends CraftEntity implements Item {
|
2021-12-22 08:07:15 +01:00
|
|
|
public void setWillAge(boolean willAge) {
|
2023-10-22 21:12:00 +02:00
|
|
|
this.getHandle().age = willAge ? 0 : NO_AGE_TIME;
|
2021-12-22 08:07:15 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int getHealth() {
|
2023-10-22 21:12:00 +02:00
|
|
|
+ return this.getHandle().health;
|
2021-12-22 08:07:15 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setHealth(int health) {
|
|
|
|
+ if (health <= 0) {
|
2023-10-22 21:12:00 +02:00
|
|
|
+ this.getHandle().getItem().onDestroyed(this.getHandle());
|
|
|
|
+ this.getHandle().discard();
|
2021-12-22 08:07:15 +01:00
|
|
|
+ } else {
|
2023-10-22 21:12:00 +02:00
|
|
|
+ this.getHandle().health = health;
|
2021-12-22 08:07:15 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-19 22:13:42 +01:00
|
|
|
// Paper end
|
2021-12-22 08:07:15 +01:00
|
|
|
|
|
|
|
@Override
|