From 4a8d483d21112c0f3623322d629622db827c7856 Mon Sep 17 00:00:00 2001
From: Newwind <support@newwindserver.com>
Date: Fri, 6 Sep 2024 23:06:32 +0100
Subject: [PATCH] Check dead flag in isAlive() (#11330)

* Create 1055-Check-dead-flag-in-isAlive().patch

* Rebase
---
 .../server/Check-dead-flag-in-isAlive.patch   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 patches/server/Check-dead-flag-in-isAlive.patch

diff --git a/patches/server/Check-dead-flag-in-isAlive.patch b/patches/server/Check-dead-flag-in-isAlive.patch
new file mode 100644
index 0000000000..f50646ee4d
--- /dev/null
+++ b/patches/server/Check-dead-flag-in-isAlive.patch
@@ -0,0 +1,29 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Newwind <support@newwindserver.com>
+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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -0,0 +0,0 @@ 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