Add entity heal API (#10267)

This commit is contained in:
TotalledZebra
2024-05-30 23:31:45 +03:00
parent ea9c42406e
commit 2cc4c182ae
2 changed files with 64 additions and 0 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 0000000000000000000000000000000000000000..00000000000000000000000000000000
*/
-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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Damageable.java
+++ b/src/main/java/org/bukkit/entity/Damageable.java
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Enderman.java