Keep restored chunk entities out of /summon's result after a level switch

Coming back to a level, the entities saved with its chunks wait in
World::loaded_entities until the next tick spawns them, as vanilla's
PersistentEntitySectionManager.processPendingLoads does. /summon pushed its
compound onto that queue and drained all of it, so the first waiting
entity took the id counted as the summon's root: after a Nether round trip
`/summon minecraft:armor_stand ...` reported "Summoned new Pig". Summon now
spawns only its own stack and leaves the queue to the tick.

The command harness's settle now waits for the entities of the chunks
around the player as well, like the oracle's settle
(areEntitiesActuallyLoadedAndTicking), and a `portal` op sends the player
through the nether portal it stands in (Entity.handlePortal:
NetherPortalBlock.getPortalDestination, teleportToPortalDestination). The
corpus's new `levels` group makes the round trip and checks the Overworld's
pig and a summon's feedback on the way back.

Fixes #947

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-19 03:07:17 +02:00
parent ba3a0fcf01
commit c0f0c17ed4
5 changed files with 76 additions and 3 deletions
+24 -1
View File
@@ -2,7 +2,8 @@
Each group is a list of operations: `cmd` runs a command as the player and
records its messages and results (`record: false` runs setup silently),
`tick` advances the game and `settle` loads the terrain around the player.
`tick` advances the game, `settle` loads the terrain and entities around the
player and `portal` sends the player through the nether portal it stands in.
Everything happens high above the terrain (y 200 and up, where both worlds
are air) after the world's entities are removed, so the results do not
depend on world generation.
@@ -394,6 +395,27 @@ def execute():
]
def levels():
"""A nether portal round trip: on the way back the Overworld's entities (the
pig left by `entities`) are found and a summon names what it summoned."""
return [
*setup('/fill 2 231 12 5 236 12 minecraft:obsidian', '/fill 3 232 12 4 235 12 minecraft:nether_portal[axis=x]',
'/tp @s 3.5 232 12.5 0 0'),
{'op': 'portal'},
{'op': 'settle'},
cmd('/execute if dimension minecraft:the_nether run say through the portal'),
{'op': 'portal'},
{'op': 'settle'},
cmd('/execute if dimension minecraft:overworld run say back through the portal'),
cmd('/data get entity @s Pos'),
cmd('/data get entity @s Rotation'),
cmd('/execute if entity @e[type=minecraft:pig]'),
cmd('/summon minecraft:armor_stand 4.5 210 4.5 {NoGravity:1b,Tags:["lv"],CustomName:"Back"}'),
*setup('/kill @e[tag=lv]', '/fill 2 231 12 5 236 12 minecraft:air', '/tp @s 8.5 230 8.5 0 0'),
{'op': 'settle'},
]
def items_and_loot():
return [
*setup('/clear @s', '/gamemode survival'),
@@ -918,6 +940,7 @@ def groups():
('entities', entities()),
('scores, teams and bossbars', scores()),
('execute', execute()),
('levels', levels()),
('items and loot', items_and_loot()),
('world', world_misc()),
('progression', progression()),