[PR #7561] Native mods: an entity's data, tags and name through EntityRef (#7387) #7671

Open
opened 2026-11-03 07:21:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7561
Author: @levzzz5154
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: modapi/entity-data


📝 Commits (2)

  • 8168e1c Native mods: an entity's data, tags and name through EntityRef (#7387)
  • e804b87 Merge remote-tracking branch 'hr/main' into modapi/entity-data

📊 Changes

8 files changed (+228 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/commands/data.rs (+1 -1)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+18 -0)
➕ crates/horizon-client/src/game/native_entity_data.rs (+85 -0)
📝 crates/horizon-client/src/game/native_entity_refs.rs (+1 -1)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+79 -0)
📝 docs/native-mods.md (+3 -0)
➕ tools/native-hook-fragments/entity_data.json (+40 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally.

Stacked on #7454 (draft until it merges; until then, review only the last commit).

Part of #7387, on top of #7454: EntityRef data, tags and name, from the lines "identity, names and tags" and "rarely used" (nbt).

What it adds

EntityRef methods:

  • nbt(host): the entity's data as /data get entity shows it. It takes &mut, because saving gives an entity without a UUID its UUID.
  • merge_nbt(host, compound): /data merge entity. It works on mobs, dropped items, armor stands and item frames. It never works on players (vanilla refuses with commands.data.entity.invalid). It returns false when nothing changed.
  • tags, add_tag, remove_tag: /tag, with the same 1024-tag limit.
  • name(host): the entity's display name as plain text.

They reuse the command code: entity_nbt, data_cmd::merged with apply_entity_nbt, and set_entity_tags, which becomes pub(in crate::game).

Proof

The probe bundle from #7454, run on this branch's fast build, server thread, offscreen, scratch homes:

ENTPROBE data name=Some("Player15084") tags=Some([]) nbt_keys=Some(["AbsorptionAmount", "Air", "DataVersion", "DeathTime", "Dimension", "EnderItems", "FallFlying", "Fire", "Health", "HurtTime", "Inventory", "Invulnerable"])
ENTPROBE data name=Some("Zombie") tags=Some([]) nbt_keys=Some(["AbsorptionAmount", "Air", "Brain", "CanBreakDoors", "CanPickUpLoot", "DeathTime", "DrownedConversionTime", "FallFlying", "Fire", "Health", "HurtTime", "InWaterTime"])
ENTPROBE data name=Some("Armor Stand") tags=Some([]) nbt_keys=Some(["AbsorptionAmount", "Air", "Brain", "DeathTime", "DisabledSlots", "FallFlying", "Fire", "Health", "HurtTime", "Invisible", "Invulnerable", "Motion"])
ENTPROBE data name=Some("Item Display") tags=Some([]) nbt_keys=Some(["Fire", "Pos", "Rotation", "UUID"])
ENTPROBE write id=1 add_tag=true again=false tags=Some(["probe"]) merge=false merge_again=false name=Some("Player15084")
ENTPROBE write id=25 add_tag=true again=false tags=Some(["probe"]) merge=true merge_again=false name=Some("Probed")
ENTPROBE write id=77 add_tag=true again=false tags=Some(["probe"]) merge=true merge_again=false name=Some("Probed")
ENTPROBE remove id=1 remove_tag=true again=false tags=Some([])
ENTPROBE remove id=387 remove_tag=false again=false tags=Some([])
  • A tag is added once, refused the second time, then removed.
  • The zombie's CustomName merge renames it and is a no-op the second time.
  • Merging into the player is refused, as in vanilla.

pr_ready (tools/pr_ready.py --quick --base modapi/entity-handles on cachyos-x8664, against modapi/entity-handles at 7b77a5ec9, 3 min 27 s)

Check Result
Scope ✅ 8 files, +228 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (32 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 19 s)
tests: horizon-client, horizon-client-lib ✅ 2158 passed (1 min 15 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
mod API up to date ✅ (12 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 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/7561 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `modapi/entity-data` --- ### 📝 Commits (2) - [`8168e1c`](https://github.com/horizon-rust/horizon/commit/8168e1c1a67c34a264c448d8f16bcde79c573f3f) Native mods: an entity's data, tags and name through EntityRef (#7387) - [`e804b87`](https://github.com/horizon-rust/horizon/commit/e804b87eee25bac1066341779bd69dc154107d65) Merge remote-tracking branch 'hr/main' into modapi/entity-data ### 📊 Changes **8 files changed** (+228 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/commands/data.rs` (+1 -1) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+18 -0) ➕ `crates/horizon-client/src/game/native_entity_data.rs` (+85 -0) 📝 `crates/horizon-client/src/game/native_entity_refs.rs` (+1 -1) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+79 -0) 📝 `docs/native-mods.md` (+3 -0) ➕ `tools/native-hook-fragments/entity_data.json` (+40 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. **Stacked on #7454** (draft until it merges; until then, review only the last commit). Part of #7387, on top of #7454: **EntityRef data, tags and name**, from the lines "identity, names and tags" and "rarely used" (`nbt`). ## What it adds `EntityRef` methods: - `nbt(host)`: the entity's data as `/data get entity` shows it. It takes `&mut`, because saving gives an entity without a UUID its UUID. - `merge_nbt(host, compound)`: `/data merge entity`. It works on mobs, dropped items, armor stands and item frames. It never works on players (vanilla refuses with `commands.data.entity.invalid`). It returns false when nothing changed. - `tags`, `add_tag`, `remove_tag`: `/tag`, with the same 1024-tag limit. - `name(host)`: the entity's display name as plain text. They reuse the command code: `entity_nbt`, `data_cmd::merged` with `apply_entity_nbt`, and `set_entity_tags`, which becomes `pub(in crate::game)`. ## Proof The probe bundle from #7454, run on this branch's fast build, server thread, offscreen, scratch homes: ``` ENTPROBE data name=Some("Player15084") tags=Some([]) nbt_keys=Some(["AbsorptionAmount", "Air", "DataVersion", "DeathTime", "Dimension", "EnderItems", "FallFlying", "Fire", "Health", "HurtTime", "Inventory", "Invulnerable"]) ENTPROBE data name=Some("Zombie") tags=Some([]) nbt_keys=Some(["AbsorptionAmount", "Air", "Brain", "CanBreakDoors", "CanPickUpLoot", "DeathTime", "DrownedConversionTime", "FallFlying", "Fire", "Health", "HurtTime", "InWaterTime"]) ENTPROBE data name=Some("Armor Stand") tags=Some([]) nbt_keys=Some(["AbsorptionAmount", "Air", "Brain", "DeathTime", "DisabledSlots", "FallFlying", "Fire", "Health", "HurtTime", "Invisible", "Invulnerable", "Motion"]) ENTPROBE data name=Some("Item Display") tags=Some([]) nbt_keys=Some(["Fire", "Pos", "Rotation", "UUID"]) ENTPROBE write id=1 add_tag=true again=false tags=Some(["probe"]) merge=false merge_again=false name=Some("Player15084") ENTPROBE write id=25 add_tag=true again=false tags=Some(["probe"]) merge=true merge_again=false name=Some("Probed") ENTPROBE write id=77 add_tag=true again=false tags=Some(["probe"]) merge=true merge_again=false name=Some("Probed") ENTPROBE remove id=1 remove_tag=true again=false tags=Some([]) ENTPROBE remove id=387 remove_tag=false again=false tags=Some([]) ``` - A tag is added once, refused the second time, then removed. - The zombie's `CustomName` merge renames it and is a no-op the second time. - Merging into the player is refused, as in vanilla. **pr_ready** (`tools/pr_ready.py --quick --base modapi/entity-handles` on cachyos-x8664, against modapi/entity-handles at 7b77a5ec9, 3 min 27 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +228 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (32 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 19 s) | | tests: horizon-client, horizon-client-lib | ✅ 2158 passed (1 min 15 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (12 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7671
No description provided.