mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 02:55:47 +01:00
Allow zero revive health when it matches maxHealth
Apparently a zero max health attribute is perfectly fine in vanilla and our own revive handling code appears to handle the case fine, even when EntityDeathEvent is cancelled. So we should allow it to avoid issues when these mobs are killed.
This commit is contained in:
parent
917d582441
commit
ec1012b5d5
@ -1,4 +1,4 @@
|
|||||||
From c3e3a14ed619bbe7b1eb5af0a11c333dd495652b Mon Sep 17 00:00:00 2001
|
From aef4c17d56b4333e03d4a071b0f3fd61a7c9bab8 Mon Sep 17 00:00:00 2001
|
||||||
From: Phoenix616 <mail@moep.tv>
|
From: Phoenix616 <mail@moep.tv>
|
||||||
Date: Tue, 21 Aug 2018 01:32:28 +0100
|
Date: Tue, 21 Aug 2018 01:32:28 +0100
|
||||||
Subject: [PATCH] Improve death events
|
Subject: [PATCH] Improve death events
|
||||||
@ -15,7 +15,7 @@ items and experience which is otherwise only properly possible by using
|
|||||||
internal code.
|
internal code.
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
diff --git a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
||||||
index ab9e81fd2..a7b8f869c 100644
|
index ab9e81fd..fef134c6 100644
|
||||||
--- a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
--- a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
||||||
+++ b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
+++ b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
||||||
@@ -8,10 +8,19 @@ import org.bukkit.inventory.ItemStack;
|
@@ -8,10 +8,19 @@ import org.bukkit.inventory.ItemStack;
|
||||||
@ -74,7 +74,7 @@ index ab9e81fd2..a7b8f869c 100644
|
|||||||
+ */
|
+ */
|
||||||
+ public void setReviveHealth(double reviveHealth) throws IllegalArgumentException {
|
+ public void setReviveHealth(double reviveHealth) throws IllegalArgumentException {
|
||||||
+ double maxHealth = ((LivingEntity) entity).getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue();
|
+ double maxHealth = ((LivingEntity) entity).getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
+ if ((reviveHealth <= 0) || (reviveHealth > maxHealth)) {
|
+ if ((maxHealth != 0 && reviveHealth <= 0) || (reviveHealth > maxHealth)) {
|
||||||
+ throw new IllegalArgumentException("Health must be between 0 (exclusive) and " + maxHealth + " (inclusive), but was " + reviveHealth);
|
+ throw new IllegalArgumentException("Health must be between 0 (exclusive) and " + maxHealth + " (inclusive), but was " + reviveHealth);
|
||||||
+ }
|
+ }
|
||||||
+ this.reviveHealth = reviveHealth;
|
+ this.reviveHealth = reviveHealth;
|
||||||
|
Loading…
Reference in New Issue
Block a user