[PR #7398] Native mods: every entity holds attachments #7578

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

📋 Pull Request Information

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

Base: main ← Head: v2/ses_01M6BECNQ499TYMMBQBDF00VJ5-entity-holders


📝 Commits (6)

  • e3fa03a Native mods: every entity holds attachments
  • b900460 Merge remote-tracking branch 'upstream/main' into entity-holders
  • 6569291 Merge remote-tracking branch 'upstream/main' into entity-holders
  • b7b0de9 Merge remote-tracking branch 'upstream/main' into entity-holders
  • d0f4655 Merge remote-tracking branch 'upstream/main' into entity-holders
  • 7786fa8 Native mods: a loaded ominous item spawner keeps its UUID and attachments

📊 Changes

6 files changed (+96 additions, -70 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/data.rs (+4 -2)
📝 crates/horizon-client/src/game/entity.rs (+12 -0)
📝 crates/horizon-client/src/game/mod_api_host.rs (+9 -15)
📝 crates/horizon-client/src/game/ominous_item_spawner.rs (+7 -3)
📝 crates/horizon-client/src/game/persist.rs (+56 -46)
📝 docs/native-mods.md (+8 -4)

📄 Description

🤖 Opened by Aria's agent swarm, Dyna, not by Aria.

Every entity holds attachments. This is #6452's "every entity as an attachment holder" item, a follow-up to #6734, which gave the level one walk over its entities.

Before this change, Holder::Entity(id) worked only for kinds that kept a UUID by entity id: mobs, items, boats, minecarts, armor stands and the rest of the old list. These kinds answered MissingHolder:

  • experience orbs, projectiles and tridents;
  • falling blocks;
  • End crystals, the dragon and ominous item spawners.

Apart from tridents, which keep their UUID by id since #7390, these kinds were saved through an anonymous (kind, position) record that held their UUID. That record lost the UUID when the entity moved before a save, and it had no attachments.

NeoForge counterpart: every Entity is an IAttachmentHolder (public javadoc), which is what this matches.

How

  • persist.rs: every loaded entity keeps its UUID by id in persist.uuids, as TNT, rockets and tridents already did.
    • A new remember_uuid stores the UUID and reads the entity's horizon:attachments. remember (which tridents use) and the load paths for orbs, projectiles, falling blocks, the dragon and crystals call it.
    • The save paths take the UUID from there (saved_uuid), so a moved arrow saves under its own UUID.
    • The anonymous record now holds only (position, raw tag).
  • The holder check (attachment_entity_exists) and prune_entity_memory walk #6734's for_each_entity!, plus a new entity_ids_off_walk() for the kinds that aren't in it. A kind added to entity_lists! becomes a holder without another edit.
  • Fixes an existing bug. On main, prune_entity_memory builds its live set from a hand-written list. Firework rockets aren't in that list. So at the end of every autosave, each rocket in flight lost its UUID and its attachments. Walking the shared lists fixes this.
  • /data on a crystal or the dragon reads the UUID from the same map.

Limit (in the docs): an orb saved with a count above one loads as several orbs. Only the first keeps the attachments.

Tested in game

The test used a throwaway trait bundle built through the launcher with native-build --trust-native-code:

  • The attachment: AttachmentType<i32> holdproof:mark, with a codec.
  • The hook (entity_join_level): a fresh entity gets 1000 + id, printed as HOLD set …. An entity loaded from disk prints get_existing, as HOLD loaded ….

Each kind was summoned, the world saved and restarted, and the value read back, with a zombie as the control.

Kind Server thread (set → reloaded id: value) Dedicated server, with a client joined
Arrow 442 → 89: Some(1442) 171 → 153: Some(1171)
Snowball 443 → 90: Some(1443) 172 → 154: Some(1172)
Experience orb 444 → 88: Some(1444) 173 → 152: Some(1173)
Falling block 445 → 87: Some(1445) 174 → 151: Some(1174)
Trident 446 → 92: Some(1446) 175 → 156: Some(1175)
Firework rocket 447 → 91: Some(1447) 176 → 155: Some(1176)
Primed TNT 448 → 86: Some(1448) 177 → 150: Some(1177)
Zombie (control) 449 → 85: Some(1449) 178 → 149: Some(1178)

Every set returned Ok(()). An arrow shot from a bow on the server thread (id 403) also reloaded as id 21 with Some(1403).

Checked by reading the code, not in game: End crystals and the dragon. Their load and save paths use the same remember_uuid and saved_uuid as the kinds above. When the runs were made, the join hook didn't report them (#7267 adds that).

Ominous item spawners: the first head missed their loader, so a loaded spawner's attachments weren't read back and its next save used a new UUID. Review commit 7786fa855 adds the remember_uuid call there. Not run in game: it needs a trial spawner set up just for this check.

These game runs were at e3fa03a0e0. The head only merges main 549d6b9cd, which stamps the pending native hook fragments and brings in #7267's leave and join for every kind. It passes xtask mod-api --check, so the same build is reused.

The recommended end-to-end route for native mods is horizon-machine-sample. It wasn't used as is. A throwaway trait bundle with the same [api] layout carried the one test hook.

pr_ready

Run at head d0f4655dc6.

pr_ready (tools/pr_ready.py --quick --base 549d6b9cd on f2196cc12001, against 549d6b9cd at 549d6b9cd, 4 min 24 s)

Check Result
Scope ✅ 5 files, +89 −67
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (40 s)
rustfmt ✅ (9 s)
clippy ✅ (1 min 31 s)
tests: horizon-client ✅ 697 passed (1 min 47 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
mod API up to date ✅ (16 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 Dyna.


🔄 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/7398 **Author:** [@arismoko](https://github.com/arismoko) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `v2/ses_01M6BECNQ499TYMMBQBDF00VJ5-entity-holders` --- ### 📝 Commits (6) - [`e3fa03a`](https://github.com/horizon-rust/horizon/commit/e3fa03a0e09295c2c306b0b9f4ccbcecc4fb330c) Native mods: every entity holds attachments - [`b900460`](https://github.com/horizon-rust/horizon/commit/b9004603f88a4fdbd55002c9b18a2301a624b863) Merge remote-tracking branch 'upstream/main' into entity-holders - [`6569291`](https://github.com/horizon-rust/horizon/commit/656929153fed3dd583ce56778526ff725c79be86) Merge remote-tracking branch 'upstream/main' into entity-holders - [`b7b0de9`](https://github.com/horizon-rust/horizon/commit/b7b0de986604d2955785ac5805a6f7ffa14d8910) Merge remote-tracking branch 'upstream/main' into entity-holders - [`d0f4655`](https://github.com/horizon-rust/horizon/commit/d0f4655dc6f4ec6195b5c10f9a749d2e9543ad29) Merge remote-tracking branch 'upstream/main' into entity-holders - [`7786fa8`](https://github.com/horizon-rust/horizon/commit/7786fa8559cf109ff0ed644acbaffa944f2abb44) Native mods: a loaded ominous item spawner keeps its UUID and attachments ### 📊 Changes **6 files changed** (+96 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/data.rs` (+4 -2) 📝 `crates/horizon-client/src/game/entity.rs` (+12 -0) 📝 `crates/horizon-client/src/game/mod_api_host.rs` (+9 -15) 📝 `crates/horizon-client/src/game/ominous_item_spawner.rs` (+7 -3) 📝 `crates/horizon-client/src/game/persist.rs` (+56 -46) 📝 `docs/native-mods.md` (+8 -4) </details> ### 📄 Description > 🤖 Opened by Aria's agent swarm, Dyna, not by Aria. **Every entity holds attachments.** This is #6452's "every entity as an attachment holder" item, a follow-up to #6734, which gave the level one walk over its entities. Before this change, `Holder::Entity(id)` worked only for kinds that kept a UUID by entity id: mobs, items, boats, minecarts, armor stands and the rest of the old list. These kinds answered `MissingHolder`: - experience orbs, projectiles and tridents; - falling blocks; - End crystals, the dragon and ominous item spawners. Apart from tridents, which keep their UUID by id since #7390, these kinds were saved through an anonymous `(kind, position)` record that held their UUID. That record lost the UUID when the entity moved before a save, and it had no attachments. NeoForge counterpart: every `Entity` is an `IAttachmentHolder` (public javadoc), which is what this matches. ## How - **`persist.rs`:** every loaded entity keeps its UUID by id in `persist.uuids`, as TNT, rockets and tridents already did. - A new `remember_uuid` stores the UUID and reads the entity's `horizon:attachments`. `remember` (which tridents use) and the load paths for orbs, projectiles, falling blocks, the dragon and crystals call it. - The save paths take the UUID from there (`saved_uuid`), so a moved arrow saves under its own UUID. - The anonymous record now holds only `(position, raw tag)`. - **The holder check** (`attachment_entity_exists`) and **`prune_entity_memory`** walk #6734's `for_each_entity!`, plus a new `entity_ids_off_walk()` for the kinds that aren't in it. A kind added to `entity_lists!` becomes a holder without another edit. - **Fixes an existing bug.** On main, `prune_entity_memory` builds its live set from a hand-written list. Firework rockets aren't in that list. So at the end of every autosave, each rocket in flight lost its UUID and its attachments. Walking the shared lists fixes this. - **`/data` on a crystal or the dragon** reads the UUID from the same map. **Limit (in the docs):** an orb saved with a `count` above one loads as several orbs. Only the first keeps the attachments. ## Tested in game The test used a throwaway trait bundle built through the launcher with `native-build --trust-native-code`: - **The attachment:** `AttachmentType<i32>` `holdproof:mark`, with a codec. - **The hook (`entity_join_level`):** a fresh entity gets `1000 + id`, printed as `HOLD set …`. An entity loaded from disk prints `get_existing`, as `HOLD loaded …`. Each kind was summoned, the world saved and restarted, and the value read back, with a zombie as the control. | Kind | Server thread (set → reloaded id: value) | Dedicated server, with a client joined | | --- | --- | --- | | Arrow | 442 → 89: `Some(1442)` | 171 → 153: `Some(1171)` | | Snowball | 443 → 90: `Some(1443)` | 172 → 154: `Some(1172)` | | Experience orb | 444 → 88: `Some(1444)` | 173 → 152: `Some(1173)` | | Falling block | 445 → 87: `Some(1445)` | 174 → 151: `Some(1174)` | | Trident | 446 → 92: `Some(1446)` | 175 → 156: `Some(1175)` | | Firework rocket | 447 → 91: `Some(1447)` | 176 → 155: `Some(1176)` | | Primed TNT | 448 → 86: `Some(1448)` | 177 → 150: `Some(1177)` | | Zombie (control) | 449 → 85: `Some(1449)` | 178 → 149: `Some(1178)` | Every `set` returned `Ok(())`. An arrow shot from a bow on the server thread (id 403) also reloaded as id 21 with `Some(1403)`. **Checked by reading the code, not in game:** End crystals and the dragon. Their load and save paths use the same `remember_uuid` and `saved_uuid` as the kinds above. When the runs were made, the join hook didn't report them (#7267 adds that). **Ominous item spawners:** the first head missed their loader, so a loaded spawner's attachments weren't read back and its next save used a new UUID. Review commit 7786fa855 adds the `remember_uuid` call there. Not run in game: it needs a trial spawner set up just for this check. These game runs were at e3fa03a0e0. The head only merges main 549d6b9cd, which stamps the pending native hook fragments and brings in #7267's leave and join for every kind. It passes `xtask mod-api --check`, so the same build is reused. The recommended end-to-end route for native mods is [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample). It wasn't used as is. A throwaway trait bundle with the same `[api]` layout carried the one test hook. ## pr_ready Run at head d0f4655dc6. **pr_ready** (`tools/pr_ready.py --quick --base 549d6b9cd` on f2196cc12001, against 549d6b9cd at 549d6b9cd, 4 min 24 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +89 −67 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (40 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 31 s) | | tests: horizon-client | ✅ 697 passed (1 min 47 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (16 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 Dyna. --- <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#7578
No description provided.