diff --git a/crates/horizon-client/src/game/commands/data.rs b/crates/horizon-client/src/game/commands/data.rs index 89e3d6397..6e4c9825f 100644 --- a/crates/horizon-client/src/game/commands/data.rs +++ b/crates/horizon-client/src/game/commands/data.rs @@ -65,9 +65,10 @@ impl Game<'_> { tag } Target::Mob(id) => { - let uuid = self.uuid_for(id); - let m = self.mobs.iter().find(|m| m.id == id)?; - entity_nbt::mob_to_nbt(m, uuid, self.persist.raw.get(&id)) + // `saveWithoutId` writes the entity as saved, riders under + // `Passengers`: `/data get` reads the same tree persistence does (#1519). + let i = self.mobs.iter().position(|m| m.id == id)?; + self.mob_tree_nbt(i) } Target::Item(id) => { let uuid = self.uuid_for(id); diff --git a/tools/command_exec_corpus.py b/tools/command_exec_corpus.py index 2b2a0afd1..eacc52a32 100644 --- a/tools/command_exec_corpus.py +++ b/tools/command_exec_corpus.py @@ -280,6 +280,12 @@ def entities(): cmd('/execute as @e[tag=h] run say mob'), cmd('/execute store result score @s harness_score run data get entity @s SelectedItemSlot'), cmd('/kill @e[tag=h]'), + # A live rider travels with its vehicle in `/data get`, the way `saveWithoutId` + # writes it (#1519): the pig is mounted, so its health is the nested value. + cmd('/summon minecraft:cow 4.5 210 8.5 {Tags:["root"],NoAI:1b,Passengers:[{id:"minecraft:pig",NoAI:1b}]}'), + cmd('/data get entity @e[tag=root,limit=1] Passengers[0].Health'), + cmd('/data get entity @e[tag=root,limit=1] Passengers[0].id'), + cmd('/kill @e[tag=root]'), *setup('/kill @e[type=minecraft:armor_stand]'), {'op': 'tick', 'n': 25}, cmd('/execute if entity @e[tag=h]'),