[PR #5692] [MERGED] feat(mods): content mods' thrown entity types are saved, summoned and listed #6440

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5692
Author: @reservedbytes
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @levzzz5154

Base: main ← Head: feat/content-entity-types-save-summon


📝 Commits (3)

  • d81a16f feat(mods): content mods' thrown entity types are saved, summoned and listed
  • ac68376 Merge remote-tracking branch 'hr/main' into pr-5692
  • a77659a fix(mods): mod entity rows appended as text; the summon test compiles

📊 Changes

9 files changed (+139 additions, -25 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+42 -2)
📝 crates/horizon-client/src/game/chat.rs (+3 -0)
📝 crates/horizon-client/src/game/commands.rs (+25 -11)
📝 crates/horizon-client/src/game/persist.rs (+4 -3)
📝 crates/horizon-client/src/mobs.rs (+1 -1)
📝 crates/horizon-client/src/mod_content.rs (+40 -2)
📝 crates/horizon-client/src/mod_content_tests.rs (+12 -0)
📝 crates/horizon-client/src/projectiles.rs (+8 -3)
📝 docs/mods.md (+4 -3)

📄 Description

What and why

Part of #5212

A content mod's thrown entity type needs to outlive its chunk, to be made by commands, and to be known to everything that reads entity types
It is now saved with its chunk as the vanilla thrown items are: its own id as id, its declared item as Item, and Projectile's keys
It loads back with its flight and owner, and it is removed with its chunk when the chunk unloads
Its loaded compound (UUID, custom name, tags, a summoned Item) stays while it has not moved, as for vanilla's thrown items
The thrown kinds share one reader, so a mod type is found by its id after vanilla's three

/summon <id>:<name> makes one, with or without NBT (Motion, Owner and the rest load as from a save)
The NBT form used to strip the namespace and put minecraft: back, which no mod id survives
Feedback names it from its own namespace (entity.<id>.<name>), and the summon suggestions list the mod types

Each mod type gets its template's row in entity-types.json (width, height, eye height, category)
So execute anchored eyes, spawner type checks and the commands' entity type list (reg.entity_types, the fallback list and stat criteria) know it

A content root now rewrites entity-types.json, so serde_json takes float_roundtrip here
Without it, 0.23000000417232513 (the movement_speed of zombies, husks, drowned, zombie villagers, zombified piglins, sheep and blazes) read back one ulp off in any world with a content mod
None of the tables a content root already rewrote on main holds a float that shifts (checked over the prepared data), so this changes no existing root
Cargo.lock is unchanged

A world opened without the mod keeps a saved mod projectile as it is, as Horizon keeps any entity it doesn't know
Until its mod is back it stays frozen in place, as a compound written back unchanged
Vanilla drops an entity whose id it doesn't know (Skipping Entity with id)
I kept Horizon's rule, because that path serves every unknown id, not only these

Checked in a real game with a fresh HORIZON_HOME on the default server thread, with a small test mod
Two bolts summoned at y 250, one of them with Motion up, are saved with their id and item
After a quit and a reopen they are loaded, and a save two seconds later still holds both
The in-frame path wasn't run: on this base it stops at world start with or without the mod, a renderer error that is tracked separately
Tests: a mod type's save and load round trip (id, item, flight, NoGravity), an id no mod declares is not a thrown kind, the summon name key, and the content-root test that the type's row is the snowball's and a zombie's speed stays vanilla's to the bit

save_roundtrip passes on this branch (run locally against the 26.3 server jar)

Left as is: a dispenser doesn't throw a mod type
Left as is: a vanilla client on a server with a mod type may be disconnected when one spawns

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

world/entity/projectile/throwableitemprojectile/ThrowableItemProjectile.java:56-65 (Item)
server/commands/SummonCommand.java:81-98 (createEntity: the type's id over the given compound, loadEntityRecursive)
world/entity/EntityType.java:502 (entity.<namespace>.<path>) and :268
world/entity/EntityType.java:321-327 (an unknown id is skipped)

Other projects' code

none

Self-check

Check Result
Scope ✅ 10 files, +108 −25
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (1 min 0 s)
rustfmt ✅ (9 s)
clippy ✅ (1 min 21 s)
tests: horizon-client ✅ 1637 passed (5 min 17 s)
doc tests ✅ 0 passed (1 s)
content root tests ✅ 20 passed (1 min 17 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)

🔄 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/5692 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `feat/content-entity-types-save-summon` --- ### 📝 Commits (3) - [`d81a16f`](https://github.com/horizon-rust/horizon/commit/d81a16f409c22fc17e088140d8ba07a2eab02640) feat(mods): content mods' thrown entity types are saved, summoned and listed - [`ac68376`](https://github.com/horizon-rust/horizon/commit/ac68376123b30767e409bcc64812505eda6c3839) Merge remote-tracking branch 'hr/main' into pr-5692 - [`a77659a`](https://github.com/horizon-rust/horizon/commit/a77659a199cddad66dde7c7ad0bf449bc2d8cc97) fix(mods): mod entity rows appended as text; the summon test compiles ### 📊 Changes **9 files changed** (+139 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+42 -2) 📝 `crates/horizon-client/src/game/chat.rs` (+3 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+25 -11) 📝 `crates/horizon-client/src/game/persist.rs` (+4 -3) 📝 `crates/horizon-client/src/mobs.rs` (+1 -1) 📝 `crates/horizon-client/src/mod_content.rs` (+40 -2) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+12 -0) 📝 `crates/horizon-client/src/projectiles.rs` (+8 -3) 📝 `docs/mods.md` (+4 -3) </details> ### 📄 Description ## What and why Part of #5212 A content mod's thrown entity type needs to outlive its chunk, to be made by commands, and to be known to everything that reads entity types It is now saved with its chunk as the vanilla thrown items are: its own id as `id`, its declared item as `Item`, and `Projectile`'s keys It loads back with its flight and owner, and it is removed with its chunk when the chunk unloads Its loaded compound (UUID, custom name, tags, a summoned `Item`) stays while it has not moved, as for vanilla's thrown items The thrown kinds share one reader, so a mod type is found by its id after vanilla's three `/summon <id>:<name>` makes one, with or without NBT (`Motion`, `Owner` and the rest load as from a save) The NBT form used to strip the namespace and put `minecraft:` back, which no mod id survives Feedback names it from its own namespace (`entity.<id>.<name>`), and the summon suggestions list the mod types Each mod type gets its template's row in `entity-types.json` (width, height, eye height, category) So `execute anchored eyes`, spawner type checks and the commands' entity type list (`reg.entity_types`, the fallback list and stat criteria) know it A content root now rewrites `entity-types.json`, so `serde_json` takes `float_roundtrip` here Without it, `0.23000000417232513` (the `movement_speed` of zombies, husks, drowned, zombie villagers, zombified piglins, sheep and blazes) read back one ulp off in any world with a content mod None of the tables a content root already rewrote on `main` holds a float that shifts (checked over the prepared data), so this changes no existing root `Cargo.lock` is unchanged A world opened without the mod keeps a saved mod projectile as it is, as Horizon keeps any entity it doesn't know Until its mod is back it stays frozen in place, as a compound written back unchanged Vanilla drops an entity whose id it doesn't know (`Skipping Entity with id`) I kept Horizon's rule, because that path serves every unknown id, not only these Checked in a real game with a fresh `HORIZON_HOME` on the default server thread, with a small test mod Two bolts summoned at y 250, one of them with `Motion` up, are saved with their id and item After a quit and a reopen they are loaded, and a save two seconds later still holds both The in-frame path wasn't run: on this base it stops at world start with or without the mod, a renderer error that is tracked separately Tests: a mod type's save and load round trip (id, item, flight, `NoGravity`), an id no mod declares is not a thrown kind, the summon name key, and the content-root test that the type's row is the snowball's and a zombie's speed stays vanilla's to the bit `save_roundtrip` passes on this branch (run locally against the 26.3 server jar) Left as is: a dispenser doesn't throw a mod type Left as is: a vanilla client on a server with a mod type may be disconnected when one spawns ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `world/entity/projectile/throwableitemprojectile/ThrowableItemProjectile.java:56-65` (`Item`) `server/commands/SummonCommand.java:81-98` (`createEntity`: the type's id over the given compound, `loadEntityRecursive`) `world/entity/EntityType.java:502` (`entity.<namespace>.<path>`) and `:268` `world/entity/EntityType.java:321-327` (an unknown id is skipped) ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 10 files, +108 −25 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (1 min 0 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 21 s) | | tests: horizon-client | ✅ 1637 passed (5 min 17 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ✅ 20 passed (1 min 17 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) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:20:38 +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#6440
No description provided.