Add entity heal API (#10267)

This commit is contained in:
TotalledZebra 2024-05-30 23:31:45 +03:00 committed by GitHub
parent a47e11d464
commit 3181470ad7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 87 additions and 23 deletions

View file

@ -12,6 +12,7 @@ Co-authored-by: Amin <amin.haddou@frg.wwschool.de>
Co-authored-by: TrollyLoki <trollyloki@gmail.com>
Co-authored-by: FireInstall <kettnerl@hu-berlin.de>
Co-authored-by: maxcom1 <46265094+maxcom1@users.noreply.github.com>
Co-authored-by: TotalledZebra <Holappa57@gmail.com>
diff --git a/src/main/java/io/papermc/paper/entity/SchoolableFish.java b/src/main/java/io/papermc/paper/entity/SchoolableFish.java
new file mode 100644
@ -348,6 +349,36 @@ index 191ce6c0e32ab3d05b1376e0fa56d1292c2d442c..8de09075e14a08a6c68f9c24e8960cc0
*/
-public interface Cod extends Fish { }
+public interface Cod extends io.papermc.paper.entity.SchoolableFish { } // Paper - Schooling Fish API
diff --git a/src/main/java/org/bukkit/entity/Damageable.java b/src/main/java/org/bukkit/entity/Damageable.java
index c4537080ee1875e984356eee42337a1342f4c9a3..f89edd9c129802f70eac022ff6bf80bef378f5e8 100644
--- a/src/main/java/org/bukkit/entity/Damageable.java
+++ b/src/main/java/org/bukkit/entity/Damageable.java
@@ -53,6 +53,25 @@ public interface Damageable extends Entity {
*/
void setHealth(double health);
+ // Paper start - entity heal API
+ /**
+ * Heal this entity by the given amount. This will call {@link org.bukkit.event.entity.EntityRegainHealthEvent}.
+ *
+ * @param amount heal amount
+ */
+ default void heal(final double amount) {
+ this.heal(amount, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.CUSTOM);
+ }
+
+ /**
+ * Heal this entity by the given amount. This will call {@link org.bukkit.event.entity.EntityRegainHealthEvent}.
+ *
+ * @param amount heal amount
+ * @param reason heal reason
+ */
+ void heal(double amount, @NotNull org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason reason);
+ // Paper end - entity heal API
+
/**
* Gets the entity's absorption amount.
*
diff --git a/src/main/java/org/bukkit/entity/Enderman.java b/src/main/java/org/bukkit/entity/Enderman.java
index 58191017244f3949f6174fb108e3a245738a53c4..61672c6faf94aa497145aadd634bb10103c7b05a 100644
--- a/src/main/java/org/bukkit/entity/Enderman.java