2024-09-07 00:06:32 +02:00
|
|
|
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
|
2024-10-25 12:30:19 +02:00
|
|
|
index ab9eec00c8c7d4b9501c6c860065909263da0b10..6db0613904c172fb6ae7e868f542f56aeaa63a5e 100644
|
2024-09-07 00:06:32 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-10-25 00:08:35 +02:00
|
|
|
@@ -2147,7 +2147,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-09-07 00:06:32 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isAlive() {
|
|
|
|
- return !this.isRemoved() && this.getHealth() > 0.0F;
|
|
|
|
+ return !this.isRemoved() && this.getHealth() > 0.0F && !this.dead; // Paper - Check this.dead
|
|
|
|
}
|
|
|
|
|
2024-10-25 00:08:35 +02:00
|
|
|
public boolean isLookingAtMe(LivingEntity entity, double d0, boolean flag, boolean visualShape, Predicate<LivingEntity> predicate, DoubleSupplier... entityYChecks) {
|