Skip to content

Check dead flag in isAlive()#11330

Merged
Machine-Maker merged 2 commits into
PaperMC:masterfrom
NewwindServer:check-dead-flag
Sep 6, 2024
Merged

Check dead flag in isAlive()#11330
Machine-Maker merged 2 commits into
PaperMC:masterfrom
NewwindServer:check-dead-flag

Conversation

@NewwindServer
Copy link
Copy Markdown
Contributor

@NewwindServer NewwindServer commented Aug 26, 2024

If a plugin sets the health of a living entity above 0 after it has already died, but before its death ticks reach 20 and remove it fully, 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

@NewwindServer NewwindServer requested a review from a team as a code owner August 26, 2024 13:08
@Machine-Maker Machine-Maker merged commit 3db4758 into PaperMC:master Sep 6, 2024
LeonTG pushed a commit to LeonTG/Paper that referenced this pull request May 17, 2026
* Create 1055-Check-dead-flag-in-isAlive().patch

* Rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

4 participants