The bug
Chunk positions of entities are not updated when they are moved to another chunk by /teleport
, /data modify
or /execute store
until entity ticking.
Steps to reproduce
/summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true}
/teleport 0-0-0-0-0 1000000 0 0
Reopen the world.
❌ The following warning message is printed, and the level fails to load the entity.Wrong location! (62500, 0) should be (0, 0), avh['Armor Stand'/5, l='world', x=1000000.50, y=0.00, z=0.50]
Code analysis
net.minecraft.server.level.ServerLevel#updateChunkPos
should be called to update entities among entity sections, but it's not called in the above commands. Entities moved to another chunk will not be re-added to the proper entity section until ServerLevel#tickNonPassenger
that includes updateChunkPos
is called.
In the reproduction steps, the entity teleported to the chunk [62500, 0]
has Pos=[1000000.5d, 0.0d, 0.5d]
, but it's still in the chunk [0, 0]
since the chunk [62500, 0]
is not an entity ticking chunk. This inconsistency causes the failure on entity loading.
Comparison with /spreadplayers
No inconsistency occurs in /spreadplayers
since it calls Entity#teleportToWithTicket
on success. Entity#teleportToWithTicket
adds a region ticket with level 0, updates tickets, and then calls Entity#teleportTo
that includes ServerLevel#updateChunkPos
.
Possible solutions
Load the destination chunk.
Throw an exception and don't move the target entities if the destination chunk is not loaded.
Related issues
Comments


Can you still reproduce this in the latest snapshot?

Can you still reproduce this in the latest snapshot?

Yes, this still affects 20w18a, but this is the duplicate of MC-108469 from the perspective both of phenomena and code analyses.
Could you close this ticket as Duplicate?
Duplicated by MC-108469