/teleport does not update chunk positions of entities
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.
Linked Issues
Created Issue:
Teleporting entity to inaccessible chunks causes data inconsistency
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular UUID maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0
function test_0-1
forceload add 1000000 0
function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC] found in regular ID map [MC] found in regular UUID map [MC] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC] found in regular ID map [MC] found in regular UUID map [MC] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place (or found in all places).
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC] found in regular ID map [MC] found in regular UUID map [MC] found in entity section [0, 0, 0] [Server] test 1: [MC] found in regular UUID map [Server] test 2: [MC] found in regular ID map [MC] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular UUID maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0
function test_0-1
forceload add 1000000 0
function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC] found in regular ID map [MC] found in regular UUID map [MC] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC] found in regular ID map [MC] found in regular UUID map [MC] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place (or found in all places).
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC] found in regular ID map [MC] found in regular UUID map [MC] found in entity section [0, 0, 0] [Server] test 1: [MC] found in regular UUID map [Server] test 2: [MC] found in regular ID map [MC] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular UUID maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0
function test_0-1
forceload add 1000000 0
function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place (or found in all places).
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular UUID maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0
function test_0-1
forceload add 1000000 0
function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place (or found in all places).
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular UUID maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place (or found in all places).
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular UUID maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place
(or found in all places).In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular UUID maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0
function test_0-1
forceload add 1000000 0
function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place.
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular
UUIDmaps and entity sections.How to reproduce
Run the following commands from console.
forceload add 0 0
function test_0-1
forceload add 1000000 0
function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place.
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular entity maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place.
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular entity maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entity is not found in any place.
In test 2, the entity is found in the regular maps and the entity section [62500, 0, 0].
Actual results[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regularUUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
In test 0, the entity is found in the regular maps and the entity section [0, 0, 0].
In test 1, the entityis found in the regular UUID map.
In test 2, the entity is not found in the entity section [62500, 0, 0].
Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular entity maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
Case 1
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is not found in any place. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by checking the chunk status as @e does.
Case 2
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0] [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found in the regular maps and the entity section [62500, 0, 0]. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by adding a post_teleport ticket to the chunk and requesting the chunk as /spreadplayers does.
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
Test Description Result 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found only in the regular UUID map. 2 The entity is not found in the entity section [62500, 0, 0]. Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
Teleporting entity to inaccessible chunks causes data inconsistencyMoving entity to inaccessible chunks causes data inconsistency
The bug
Teleporting entities to inaccessible chunks causes data inconsistency between the regular entity maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
Case 1
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is not found in any place. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by checking the chunk status as @e does.
Case 2
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0] [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found in the regular maps and the entity section [62500, 0, 0]. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by adding a post_teleport ticket to the chunk and requesting the chunk as /spreadplayers does.
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
Test Description Result 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found only in the regular UUID map. 2 The entity is not found in the entity section [62500, 0, 0]. Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Moving entities to inaccessible chunks by /teleport or /data modify causes data inconsistency between the regular entity maps and entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
Case 1
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is not found in any place. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by checking the chunk status as @e does.
Case 2
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0] [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found in the regular maps and the entity section [62500, 0, 0]. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by adding a post_teleport ticket to the chunk and requesting the chunk as /spreadplayers does.
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map [Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
Test Description Result 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found only in the regular UUID map. 2 The entity is not found in the entity section [62500, 0, 0]. Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Moving entities to inaccessible chunks by /teleport
or/data modifycauses data inconsistency between the regularentitymapsand entity sections.How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1 forceload add 1000000 0 function test_2# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test_2.mcfunction say test 2: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
Case 1
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1:[Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is not found in any place. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by checking the chunk status as @e does.
Case 2
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0][Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found in the regular maps and the entity section [62500, 0, 0]. 2 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by adding a post_teleport ticket to the chunk and requesting the chunk a
s/spreadplayersdoes.Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map[Server] test 2: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map
Test Description Result 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found only in the regular UUID map. 2 The entity is not found in the entity section [62500, 0, 0]. Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atd['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Moving entities to inaccessible chunks by /teleport, /data modify or /execute store causes data inconsistency between the regular UUID map and the regular ID map/entity sections.
How to reproduce
Run the following commands from console.
forceload add 0 0 function test_0-1# test_0-1.mcfunction summon minecraft:armor_stand 0 0 0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say test 0: function test teleport 0-0-0-0-0 1000000 0 0 say test 1: function test# test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
Case 1
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1:
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is not found in any place. In this case, the entity data is kept consistent by checking the chunk status as @e does.
Case 2
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by adding a post_teleport ticket to the chunk and requesting the chunk after /teleport as /spreadplayers does.
Actual results
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map
Test Description Result 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found only in the regular UUID map. Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atg['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
Moving entity to inaccessible chunks causes data inconsistencyChunk pos of entity does not updated after crossing chunk border until ticking
The bug
Moving entities to
inaccessiblechunksby /teleport, /data modify or /execute storecauses data inconsistency between the regular UUID map and theregular ID map/entity sections.How to reproduce
Run the following commands
from console.
forceload add 0 0 function test_0-1# test_0-1.mcfunction summonminecraft:armor_stand0 0 0{UUIDMost:0L,UUIDLeast:0L,Marker:true,CustomName:'"MC-153381"'} saytest 0: function testteleport0-0-0-0-01000000 0 0 say test 1: function test
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found in the regular maps and the entity section [62500, 0, 0]. # test.mcfunction execute as @e[name=MC-153381] run say found in regular ID map execute as 0-0-0-0-0 run say found in regular UUID map execute as @e[x=0, y=0, z=0, distance=..1] run say found in entity section [0, 0, 0] execute as @e[x=1000000, y=0, z=0, distance=..1] run say found in entity section [62500, 0, 0]Expected results
Case 1
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1:
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is not found in any place. In this case, the entity data is kept consistent by checking the chunk status as @e does.
Case 2
[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [62500, 0, 0]
Test Description 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found in the regular maps and the entity section [62500, 0, 0]. In this case, the entity data is kept consistent by adding a post_teleport ticket to the chunk and requesting the chunk after /teleport as /spreadplayers does.
Actual results[Server] test 0: [MC-153381] found in regular ID map [MC-153381] found in regular UUID map [MC-153381] found in entity section [0, 0, 0] [Server] test 1: [MC-153381] found in regular UUID map
Test Description Result 0 The entity is found in the regular maps and the entity section [0, 0, 0]. 1 The entity is found only in the regular UUID map. Furthermore, the following warning message is printed and the entity is removed on server restart.
Wrong location! (62500, 0) should be (0, 0), atg['MC-153381'/1, l='world', x=1000000.50, y=0.00, z=0.50]
The bug
Moving entities to another chunk by /teleport, /data modify or /execute store does not update their chunk pos, whereas /spreadplayers does.
How to reproduce
Run the following commands.
/forceload add 1000000 0 1000016 0
/function test## test.mcfunction summon minecraft:armor_stand 1000008.0 8.0 8.0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say before teleport: function check # Move the entity to another chunk teleport 0-0-0-0-0 1000024.0 8.0 8.0 say after teleport: function check say after entity ticking: schedule function check 2## check.mcfunction # Find entities from the entity section [625000, 0, 0] say [62500, 0, 0]..[62500, 0, 0]: @e[x=1000002.0, y=2.0, z=2.0, dx=12.0, dy=12.0, dz=12.0] # Find entities from the entity sections [625000, 0, 0], [625001, 0, 0] say [62500, 0, 0]..[62501, 0, 0]: @e[x=1000002.0, y=2.0, z=2.0, dx=28.0, dy=12.0, dz=12.0] # Find entities from the entity section [625001, 0, 0] say [62501, 0, 0]..[62501, 0, 0]: @e[x=1000018.0, y=2.0, z=2.0, dx=12.0, dy=12.0, dz=12.0] # Entity pos tellraw @a ["Pos: ", {"entity" : "0-0-0-0-0", "nbt": "Pos"}]
Results
before teleport: [62500, 0, 0]..[62500, 0, 0]: MC-153381 [62500, 0, 0]..[62501, 0, 0]: MC-153381 [62501, 0, 0]..[62501, 0, 0]: Pos: [1000008.0d,8.0d,8.0d] after teleport: [62500, 0, 0]..[62500, 0, 0]: [62500, 0, 0]..[62501, 0, 0]: MC-153381 [62501, 0, 0]..[62501, 0, 0]: Pos: [1000024.0d,8.0d,8.0d] after entity ticking: [62500, 0, 0]..[62500, 0, 0]: [62500, 0, 0]..[62501, 0, 0]: MC-153381 [62501, 0, 0]..[62501, 0, 0]: MC-153381 Pos: [1000024.0d,8.0d,8.0d]
After /teleport, the entity is not found in the entity section [62501, 0, 0], but Pos is in the range of the section. After entity ticking, chunk pos of the entity is updated correctly. This means that chunk pos of an entity moved to another chunk is not updated immediately, and never updated if the destination is not entity ticking chunk.
Chunk pos of entity does not updated aftercrossing chunk borderuntil tickingChunk pos of entity does not updated after moved to another chunk until ticking
The bug
Moving entities to another chunk by /teleport, /data modify or /execute store does not update their chunk pos, whereas /spreadplayers does.
How to reproduce
Run the following commands.
/forceload add 1000000 0 1000016 0
/function test## test.mcfunction summon minecraft:armor_stand 1000008.0 8.0 8.0 {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, CustomName: '"MC-153381"'} say before teleport: function check # Move the entity to another chunk teleport 0-0-0-0-0 1000024.0 8.0 8.0 say after teleport: function check say after entity ticking: schedule function check 2## check.mcfunction # Find entities from the entity section [625000, 0, 0] say [62500, 0, 0]..[62500, 0, 0]: @e[x=1000002.0, y=2.0, z=2.0, dx=12.0, dy=12.0, dz=12.0] # Find entities from the entity sections [625000, 0, 0], [625001, 0, 0] say [62500, 0, 0]..[62501, 0, 0]: @e[x=1000002.0, y=2.0, z=2.0, dx=28.0, dy=12.0, dz=12.0] # Find entities from the entity section [625001, 0, 0] say [62501, 0, 0]..[62501, 0, 0]: @e[x=1000018.0, y=2.0, z=2.0, dx=12.0, dy=12.0, dz=12.0] # Entity pos tellraw @a ["Pos: ", {"entity": "0-0-0-0-0", "nbt": "Pos"}]
Resultsbefore teleport: [62500, 0, 0]..[62500, 0, 0]: MC-153381 [62500, 0, 0]..[62501, 0, 0]: MC-153381 [62501, 0, 0]..[62501, 0, 0]: Pos: [1000008.0d,8.0d,8.0d] after teleport: [62500, 0, 0]..[62500, 0, 0]: [62500, 0, 0]..[62501, 0, 0]: MC-153381 [62501, 0, 0]..[62501, 0, 0]: Pos: [1000024.0d,8.0d,8.0d] after entity ticking: [62500, 0, 0]..[62500, 0, 0]: [62500, 0, 0]..[62501, 0, 0]: MC-153381 [62501, 0, 0]..[62501, 0, 0]: MC-153381 Pos: [1000024.0d,8.0d,8.0d]
After /teleport, the entity is not found in the entity section [62501, 0, 0], but Pos is in the range of the section. After entity ticking, chunk pos of the entity is updated correctly. This means that chunk pos of an entity moved to another chunk is not updated immediately, and never updated if the destination is not entity ticking chunk.
Chunk pos of entity does not updated after moved to another chunk untiltickingServerLevel does not update chunk positions of entities until entity ticking
The bug
Chunk positions of entities are not updated when they are moved to another chunk by /teleport, /data modify or /execute store.
Code analysis
net.minecraft.server.level.ServerLevel#updateChunkPos is not properly called in the above commands. This method should be called to add entities to the entity section of the chunk.
The bug
Chunk positions of entities are not updated when they are moved to another chunk by /teleport, /data modify or /execute store.
Code analysis
net.minecraft.server.level.ServerLevel#updateChunkPos is not properly called in the above commands. This method should be called to add entities to the entity section of the chunk.
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.
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.
ServerLeveldoes not update chunk positions of entitiesuntil entity ticking/teleport does not update chunk positions of entities
relates to
duplicates
relates to
Duplicated by
MC-108469Can you still reproduce this in the latest snapshot?
Yes, this still affects 20w18a, but this is the duplicate of
MC-108469from the perspective both of phenomena and code analyses.Could you close this ticket as Duplicate?