aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1057-Check-dead-flag-in-isAlive.patch
diff options
context:
space:
mode:
authorNewwind <[email protected]>2024-09-06 23:06:32 +0100
committerGitHub <[email protected]>2024-09-06 15:06:32 -0700
commit3db475838f8341f0db0efee0843755864b2241fa (patch)
treef3384d8d2ef01f6e363906f86a46795ae1d4c7be /patches/server/1057-Check-dead-flag-in-isAlive.patch
parente0021b15b6b0fb1ed5a6f153425a9a83d5ff2344 (diff)
downloadPaper-3db475838f8341f0db0efee0843755864b2241fa.tar.gz
Paper-3db475838f8341f0db0efee0843755864b2241fa.zip
Check dead flag in isAlive() (#11330)
* Create 1055-Check-dead-flag-in-isAlive().patch * Rebase
Diffstat (limited to 'patches/server/1057-Check-dead-flag-in-isAlive.patch')
-rw-r--r--patches/server/1057-Check-dead-flag-in-isAlive.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/patches/server/1057-Check-dead-flag-in-isAlive.patch b/patches/server/1057-Check-dead-flag-in-isAlive.patch
new file mode 100644
index 0000000000..c7bca0ad14
--- /dev/null
+++ b/patches/server/1057-Check-dead-flag-in-isAlive.patch
@@ -0,0 +1,29 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Newwind <[email protected]>
+Date: Mon, 26 Aug 2024 14:01:37 +0200
+Subject: [PATCH] Check dead flag in isAlive()
+
+If a plugin sets the health of a living entity above 0 after it has already died, the entity will be "revived".
+It will behave the exact same as before, except with the internal "dead" flag set, resulting in 2 behavior changes,
+A: it's completely invulnerable to all damage
+B: it's unable to pickup items
+
+isValid() for these bugged entities will return true, isDead() will return false, despite the dead flag.
+This patch checks that the mob isn't dead before saying its alive.
+
+Also, even if the plugin is responsibly checking !isDead() before modifying health, on very rare circumstances
+I am currently unable to replicate, these "revived" entities can still appear
+
+diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+index ccd9dff20a60f019e0c320acfb526b8bf3e5f806..9c9e2377f44b1f1bbd8bb0e8bc963a80f4f9ee68 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -2096,7 +2096,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
+
+ @Override
+ public boolean isAlive() {
+- return !this.isRemoved() && this.getHealth() > 0.0F;
++ return !this.isRemoved() && this.getHealth() > 0.0F && !this.dead; // Paper - Check this.dead
+ }
+
+ @Override