Mojira Archive
MC-183818

[Item Duplication] Dead/Invalid entities can use portals

I suspect there is likely already issues relating to portal dupes, but since I can't access those,  and also don't want to spread the details too much, opening new with the solution to the issue.

 

Entities trying to use portals currently check .dead boolean, however this is not sufficient check.

An entity can be killed in the same tick as portaling, which results in that entity dropping its inventory contents, but then at the same time, portal to the other dimension, duplicating the contents of the inventory on the other dimension, for it to immediately die again.

The root issue lies in the fact that living entities do not set .dead = true when they die, and instead set it 20 ticks later....

Also, entities that are not considered part of the world (Spigot/Bukkit naming of entity.valid) really shouldn't be using portals either.

The fix is here:

https://github.com/PaperMC/Paper/blob/827cc63263564dd6824da9a9205235eae3e35d6c/Spigot-Server-Patches/0492-Fix-numerous-item-duplication-issues-and-teleport-is.patch#L39

and the canPortal a few lines below.

the isAlive() method needs to be checked too, as well as world validity, so that living entities that are in their 20 tick death phase, can not be portaled.

This solves End Portal and Nether Portal duplication issues.

The rest of this patch is something Vanilla should consider too, in that any time an entity is added to the world as the result of dropping an entities inventory, the source stack that was just copied into the itemstack really needs to be destroyed so that the itemstack doesn't exist in 2 places at same time in memory.

This is a defensive measure against future duplication bugs.

Cannot Reproduce

Aikar

2020-05-13, 06:28 PM

2024-11-14, 01:27 PM

2024-11-14, 01:27 PM

1

1

Plausible

Important

Platform

Items

1.15.2, 1.16.1

-