Data: /data get entity writes a mob's live riders
A mounted mob answered "Found no elements matching Passengers": the command built the entity with the flat serializer, so `Passengers` was never in the tag, even though the game had the relationship and saving a world kept it. Persistence already writes the tree (`Game::mob_tree_nbt`, which also carries the leash), and vanilla's command path uses the same one, so the command reads it now. Fixes #1519. Co-Authored-By: Hermes Agent (Nous Research) <noreply@nousresearch.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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]'),
|
||||
|
||||
Reference in New Issue
Block a user