[PR #6426] [MERGED] Save and reload keeps primed TNT, rockets and thrown tridents #6864

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6426
Author: @HrafnaValkyrja
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/save-loaded-entities


📝 Commits (2)

  • 5a226d4 Save primed TNT, firework rockets and thrown tridents
  • fd93627 Merge remote-tracking branch 'origin/main' into fix/save-loaded-entities

📊 Changes

5 files changed (+275 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+165 -0)
📝 crates/horizon-client/src/game/commands.rs (+2 -1)
📝 crates/horizon-client/src/game/fireworks.rs (+26 -0)
📝 crates/horizon-client/src/game/persist.rs (+46 -0)
📝 crates/horizon-client/src/game/trident.rs (+36 -0)

📄 Description

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

What and why

Wrong: entity_chunks had no loop for TNT, rockets or tridents, so they vanished on save and quit or chunk unload. Tridents also had no load arm, so a trident saved by vanilla stayed an inert compound forever.

Fix: save loops for the three kinds next to the falling-block loop; firework_rocket_to_nbt, trident_to_nbt / trident_from_nbt in entity_nbt; a trident load arm; the three lists leave with their chunk on unload; /summon trident counts as a spawn. Keys follow vanilla's PrimedTnt, FireworkRocketEntity, AbstractArrow and ThrownTrident addAdditionalSaveData (bytecode).

Fixes #6424

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

Vanilla reference: Entity.saveWithoutId and each kind's addAdditionalSaveData, read from the shipped bytecode.

Measured on a real vanilla 26.3 server.jar and on Horizon, same console script: forceload, freeze ticks, summon, /save-all flush, quit, read the entity region file; restart, step ticks, save, read again.

Horizon before Horizon after vanilla
TNT saved (fuse 500, 300) 0 2, fuses 500 / 300 2, fuses 500 / 300
rocket saved (Life 7, LifeTime 100000) 0 1, same 1, same
trident saved inert compound 1 live 1 live
after reload + ticks: TNT y / fuse not there 65 / 440 and 65 / 240 65 / 442 and 70 / 242
after reload + ticks: rocket y / Life not there 150.8 / 66 148.44 / 65
after reload + ticks: trident y, inGround not there 68.05, stuck 68.05, stuck

The saved keys and values match vanilla for all three kinds (position, motion, fuse, Life, LifeTime, FireworksItem, ShotAtAngle, block_state, damage, SoundEvent after the save). Full key-by-key diff of both sides is in save-diff.txt.

What was not compared or still differs:

  • The tick counts after reload differ by one to three between runs (the server is not stopped at an exact tick), so fuse 440 vs 442 and rocket 150.8 vs 148.44 are timing, not a rule.
  • Second TNT: vanilla y 70, Horizon 65. Vanilla's world has an oak leaf block there that Horizon's does not; that is world generation, not saving.
  • A rocket's Rotation is not saved (vanilla writes the flight angle, Horizon 0), a trident that has stuck in a block does not save inBlockState, and its SoundEvent stays hit_ground where vanilla switches to arrow.hit on landing.
  • HasBeenShot is 1 for a summoned rocket or trident before any tick (vanilla 0), and a summoned trident is saved with pickup 1 (vanilla 0). Owner of a rocket or trident is not restored for LAN guests.
  • A trident or potion thrown live by a player was not tested (needs a client).
  • Thrown potions, area effect clouds and a drowned's trident are still kept as inert compounds on reload (not lost, not simulated). Fishing hooks cannot be summoned and vanilla does not save them.

Proved by script against the real 26.3 server; no human played this change.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick on Valhalla, against origin/main at f4833621f, 3 min 3 s)

Check Result
Scope ✅ 5 files, +275 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 594 passed (30 s)
rustfmt ✅ (6 s)
Rust ⚠️ 1.98.0 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with rustup update
clippy ✅ (1 min 17 s)
tests: horizon-client, horizon-client-lib ✅ 1886 passed (1 min 8 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
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.ai/code/session_018zuDTsnyHkP28bzn3u7S3m


🔄 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/6426 **Author:** [@HrafnaValkyrja](https://github.com/HrafnaValkyrja) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/save-loaded-entities` --- ### 📝 Commits (2) - [`5a226d4`](https://github.com/horizon-rust/horizon/commit/5a226d458517e27cce45ced85a2b6f874ce671b9) Save primed TNT, firework rockets and thrown tridents - [`fd93627`](https://github.com/horizon-rust/horizon/commit/fd93627b14352bc3d47476e0ded24e89d1f77fd8) Merge remote-tracking branch 'origin/main' into fix/save-loaded-entities ### 📊 Changes **5 files changed** (+275 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+165 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+2 -1) 📝 `crates/horizon-client/src/game/fireworks.rs` (+26 -0) 📝 `crates/horizon-client/src/game/persist.rs` (+46 -0) 📝 `crates/horizon-client/src/game/trident.rs` (+36 -0) </details> ### 📄 Description > 🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself. ## What and why **Wrong:** `entity_chunks` had no loop for TNT, rockets or tridents, so they vanished on save and quit or chunk unload. Tridents also had no load arm, so a trident saved by vanilla stayed an inert compound forever. **Fix:** save loops for the three kinds next to the falling-block loop; `firework_rocket_to_nbt`, `trident_to_nbt` / `trident_from_nbt` in entity_nbt; a trident load arm; the three lists leave with their chunk on unload; `/summon trident` counts as a spawn. Keys follow vanilla's `PrimedTnt`, `FireworkRocketEntity`, `AbstractArrow` and `ThrownTrident` `addAdditionalSaveData` (bytecode). Fixes #6424 ## Kind - [x] 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 Vanilla reference: `Entity.saveWithoutId` and each kind's `addAdditionalSaveData`, read from the shipped bytecode. **Measured** on a real vanilla 26.3 server.jar and on Horizon, same console script: forceload, freeze ticks, summon, `/save-all flush`, quit, read the entity region file; restart, step ticks, save, read again. | | Horizon before | Horizon after | vanilla | |---|---|---|---| | TNT saved (fuse 500, 300) | 0 | 2, fuses 500 / 300 | 2, fuses 500 / 300 | | rocket saved (Life 7, LifeTime 100000) | 0 | 1, same | 1, same | | trident saved | inert compound | 1 live | 1 live | | after reload + ticks: TNT y / fuse | not there | 65 / 440 and 65 / 240 | 65 / 442 and 70 / 242 | | after reload + ticks: rocket y / Life | not there | 150.8 / 66 | 148.44 / 65 | | after reload + ticks: trident y, inGround | not there | 68.05, stuck | 68.05, stuck | The saved keys and values match vanilla for all three kinds (position, motion, fuse, Life, LifeTime, FireworksItem, ShotAtAngle, block_state, damage, SoundEvent after the save). Full key-by-key diff of both sides is in save-diff.txt. **What was not compared or still differs:** - The tick counts after reload differ by one to three between runs (the server is not stopped at an exact tick), so fuse 440 vs 442 and rocket 150.8 vs 148.44 are timing, not a rule. - Second TNT: vanilla y 70, Horizon 65. Vanilla's world has an oak leaf block there that Horizon's does not; that is world generation, not saving. - A rocket's Rotation is not saved (vanilla writes the flight angle, Horizon 0), a trident that has stuck in a block does not save `inBlockState`, and its `SoundEvent` stays hit_ground where vanilla switches to arrow.hit on landing. - `HasBeenShot` is 1 for a summoned rocket or trident before any tick (vanilla 0), and a summoned trident is saved with `pickup` 1 (vanilla 0). Owner of a rocket or trident is not restored for LAN guests. - A trident or potion thrown live by a player was not tested (needs a client). - Thrown potions, area effect clouds and a drowned's trident are still kept as inert compounds on reload (not lost, not simulated). Fishing hooks cannot be summoned and vanilla does not save them. Proved by script against the real 26.3 server; no human played this change. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Valhalla, against origin/main at f4833621f, 3 min 3 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +275 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 594 passed (30 s) | | rustfmt | ✅ (6 s) | | Rust | ⚠️ 1.98.0 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with `rustup update` | | clippy | ✅ (1 min 17 s) | | tests: horizon-client, horizon-client-lib | ✅ 1886 passed (1 min 8 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | 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) https://claude.ai/code/session_018zuDTsnyHkP28bzn3u7S3m --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:28: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#6864
No description provided.