The bug
When teleporting an entity from another dimension, the entity is added to the entity sections in the destination dimension even though there are already entities with the same UUID as the teleported entity.
How to reproduce
Mark the chunk [0, 0] in the overworld and the end to be force loaded.
/execute in minecraft:overworld run forceload add 0 0
/execute in minecraft:the_end run forceload add 0 0
Let the overworld be the destination dimension and add an entity with the UUID
0-0-0-0-24ee6
./execute in minecraft:overworld run summon minecraft:item_frame 0 0 0 {UUID: [I; 0, 0, 0, 151270], Fixed: true, CustomName: '"151270"'}
Let the end be the origin dimension and add an entity with the UUID
0-0-0-0-24ee6
./execute in minecraft:the_end run summon minecraft:item_frame 0 0 0 {UUID: [I; 0, 0, 0, 151270], Fixed: true, CustomName: '"151270"'}
Teleport the entity in the end to the overworld.
/execute in minecraft:the_end as @e[x=0, y=0, z=0, dx=0] in minecraft:overworld run teleport @s 0 0 0
→
Keeping entity minecraft:item_frame that already exists with UUID 00000000-0000-0000-0000-000000024ee6
Check entities in the entity sections.
/execute in minecraft:overworld run say @e[x=0, y=0, z=0, dx=0]
→ ❌
151270, 151270
, the entity in the end is added to the entity sections in the overworld. The entity sections in the overworld now have two entities with the same UUID0-0-0-0-24ee6
.
Code analysis
// net.minecraft.server.level.ServerLevel
public void addFromAnotherDimension(Entity entity) {
boolean forcedLoading = entity.forcedLoading;
entity.forcedLoading = true;
// Since this level already has an entity with the same UUID as `entity`, the game warns about UUID duplication and does not add `entity` to this level.
this.addWithUUID(entity);
entity.forcedLoading = forcedLoading;
// However, `entity` is added to the entity sections in this level without UUID check.
// UUID duplication in entity sections causes here.
this.updateChunkPos(entity);
}
Comments


Yes, this still affects 20w18a.
However, there are a few minor changes affecting the results. Before updating affected versions, I need to rework the description and the reproduction steps focusing on more reproducibility and UUID duplication.

Fixed in 20w45a. When adding an entity, the game now checks the known UUIDs and prints the following warning message if its UUID is duplicated.
UUID of added entity already exists: ...
Can you still reproduce this in the latest snapshot?