[PR #1664] [MERGED] Data: /data get entity writes a mob's live riders #3670

Closed
opened 2026-11-03 04:11:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1664
Author: @Domanffe
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @ludovic111

Base: main ← Head: fix/data-get-live-passengers


📝 Commits (1)

  • 977ef71 Data: /data get entity writes a mob's live riders

📊 Changes

2 files changed (+10 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/data.rs (+4 -3)
📝 tools/command_exec_corpus.py (+6 -0)

📄 Description

🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself.

Fixes #1519.

What and why

With a pig riding a cow, /data get entity @e[tag=root,limit=1] Passengers[0].Health answered "Found no elements matching Passengers", though the pig really was mounted and saving the world kept the pair.

Game::entity_nbt built the mob with the flat serializer:

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))
}

That function writes one entity and nothing about what rides it. Persistence already has the tree form, Game::mob_tree_nbt, which walks the riders and nests their own tags under Passengers (and writes the leash); the command path simply was not using it. The arm now finds the mob's index and returns mob_tree_nbt(i), which is the same tag a save writes, so the two cannot drift apart.

A rider restored from a save goes through the same function, which is the second half of the issue: the tree is built from the live mob list, not from the saved compound.

Vanilla reference

NbtPredicate.getEntityTagToCompare reads Entity.saveWithoutId, and Entity.saveWithoutId calls savePassengers, so a mounted mob's tag carries its riders recursively. The same data is what <mob>_to_nbt in entity_nbt.rs mirrors for everything else on the entity.

Coverage: a case in tools/command_exec_corpus.py (group entities) summons a cow with a pig in Passengers and asks for Passengers[0].Health and Passengers[0].id, which test_command_exec_parity compares against the vanilla oracle.

Self-check

Measured on a build of this branch, in a fresh world (cargo build --profile fast, driven with horizon-ctl):

/summon minecraft:cow ~ ~3 ~ {Tags:["root"],NoAI:1b,Passengers:[{id:"minecraft:pig",NoAI:1b}]}
/data get entity @e[tag=root,limit=1] Passengers[0].Health   -> 10.0f
/data get entity @e[tag=root,limit=1] Passengers[0].id       -> "minecraft:pig"
/data get entity @e[tag=root,limit=1] Passengers             -> the pig's whole tag, nested

Before the change the same commands answered "Found no elements matching Passengers", which is the reproduction in the issue.

The pr_ready block goes into a comment below when that run finishes.

🤖 Generated with Hermes Agent (Nous Research)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1664 **Author:** [@Domanffe](https://github.com/Domanffe) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/data-get-live-passengers` --- ### 📝 Commits (1) - [`977ef71`](https://github.com/horizon-rust/horizon/commit/977ef7181f5b38d4d11e7791653690fc876f40ae) Data: `/data get entity` writes a mob's live riders ### 📊 Changes **2 files changed** (+10 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/data.rs` (+4 -3) 📝 `tools/command_exec_corpus.py` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. Fixes #1519. ## What and why With a pig riding a cow, `/data get entity @e[tag=root,limit=1] Passengers[0].Health` answered "Found no elements matching Passengers", though the pig really was mounted and saving the world kept the pair. `Game::entity_nbt` built the mob with the flat serializer: ```rust 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)) } ``` That function writes one entity and nothing about what rides it. Persistence already has the tree form, `Game::mob_tree_nbt`, which walks the riders and nests their own tags under `Passengers` (and writes the leash); the command path simply was not using it. The arm now finds the mob's index and returns `mob_tree_nbt(i)`, which is the same tag a save writes, so the two cannot drift apart. A rider restored from a save goes through the same function, which is the second half of the issue: the tree is built from the live mob list, not from the saved compound. ## Vanilla reference `NbtPredicate.getEntityTagToCompare` reads `Entity.saveWithoutId`, and `Entity.saveWithoutId` calls `savePassengers`, so a mounted mob's tag carries its riders recursively. The same data is what `<mob>_to_nbt` in `entity_nbt.rs` mirrors for everything else on the entity. Coverage: a case in `tools/command_exec_corpus.py` (group `entities`) summons a cow with a pig in `Passengers` and asks for `Passengers[0].Health` and `Passengers[0].id`, which `test_command_exec_parity` compares against the vanilla oracle. ## Self-check Measured on a build of this branch, in a fresh world (`cargo build --profile fast`, driven with `horizon-ctl`): ``` /summon minecraft:cow ~ ~3 ~ {Tags:["root"],NoAI:1b,Passengers:[{id:"minecraft:pig",NoAI:1b}]} /data get entity @e[tag=root,limit=1] Passengers[0].Health -> 10.0f /data get entity @e[tag=root,limit=1] Passengers[0].id -> "minecraft:pig" /data get entity @e[tag=root,limit=1] Passengers -> the pig's whole tag, nested ``` Before the change the same commands answered "Found no elements matching Passengers", which is the reproduction in the issue. The `pr_ready` block goes into a comment below when that run finishes. 🤖 Generated with Hermes Agent (Nous Research) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:11:19 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3670
No description provided.