[PR #7177] [MERGED] Wind charges and lingering potions survive a save #7395

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

📋 Pull Request Information

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

Base: main ← Head: fix/save-missing-kinds


📝 Commits (3)

  • 4d83f58 Save wind charges, keep a lingering potion's type, read block-attached entities summoned without block_pos
  • f006d06 Keep a splash or lingering potion's UUID through a save
  • 15fc1ce Merge remote-tracking branch 'origin/main' into fix/save-missing-kinds

📊 Changes

6 files changed (+137 additions, -41 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+115 -23)
📝 crates/horizon-client/src/game/creatures.rs (+1 -1)
📝 crates/horizon-client/src/game/lan_entities.rs (+1 -1)
📝 crates/horizon-client/src/game/persist.rs (+2 -0)
📝 crates/horizon-client/src/mobs/witch.rs (+2 -2)
📝 crates/horizon-client/src/projectiles.rs (+16 -14)

📄 Description

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

What and why

A vanilla 26.3 world loaded in Horizon and saved lost entities (found by the round trip of #6545). This fixes the ones that are real losses:

  • Wind charges and breeze wind charges were not saved. entity_nbt::saved_with_chunk decides whether a projectile is written; it left out WindCharge and BreezeWindCharge although fireball_to_nbt writes them and fireball_from_nbt reads them, so they were lost on save (4 of 170). saved_with_chunk is now an exhaustive match with no wildcard: a new ProjectileKind does not compile until it says whether it is saved. An old test asserted that wind charges are not saved; it now asserts they are.
  • A lingering potion came back as a splash potion. ProjectileKind::Potion took its entity type from the Item stack, so a lingering_potion entity with a splash potion Item was written as splash_potion (2 of 170). The variant now carries whether its entity type is lingering (ProjectileKind::potion(stack) sets it from the item for thrown ones; loading uses the entity id).
  • Splash and lingering potions got a random UUID on each save (the saved UUID was not remembered). They are now in the same memory as the other throwables (persist.rs, 2 lines).
  • /summon painting and /summon item_frame were refused. painting_from_nbt and item_frame_from_nbt required block_pos; vanilla (BlockAttachedEntity.readAdditionalSaveData) reads it as optional, and setPos puts the block at the summon position.

Not changed: firework_rocket with LifeTime:0 and ominous_item_spawner with spawn_item_after_ticks:0 are lost in the round trip too, but vanilla loses them on a plain vanilla reload as well (measured), so that is parity.

In-flight projectiles do persist in vanilla: Entity.shouldBeSaved is true unless the entity was removed with a reason that does not save, and neither Projectile, FireworkRocketEntity nor OminousItemSpawner overrides it or isAlwaysTicking (bytecode of 26.3 server-game.jar).

Overlap with #6545 (slice 10, moving the save loops): this PR touches no loop. saved_with_chunk is called from the projectile loop in entity_chunks; if that loop becomes Entity::save_nbt, the same function is the filter. The 2-line UUID change is in spawn_loaded_entities, which slice 10 leaves alone.

Fixes #7176

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

26.3 server.jar as the oracle: BlockAttachedEntity.readAdditionalSaveData (block_pos read with orElse(null)), Entity.shouldBeSaved, the entity ids minecraft:wind_charge, minecraft:breeze_wind_charge, minecraft:lingering_potion (own type, any Item).

Proof

Round trip with the 170-entity world of #6545 (vanilla summons, 2 groups), entity region files read back, entities matched by id and position:

entities after wind breeze lingering splash paintings frames
vanilla original 170 2 2 2 2 2 2
vanilla loaded and saved again (control) 168 2 2 2 2 2 2
main: vanilla -> Horizon -> vanilla 165 0 0 0 4 2 2
this PR: vanilla -> Horizon -> vanilla 169 2 2 2 2 2 2

The control loses the rocket and the spawner. Main loses those and the wind charges and lingering potions. This PR keeps all of them; the totals differ from the control by the eye of ender entities, which vanilla removes after 80 ticks (a timing effect of the harness, noted in #6545). In the field diff against the control (matched by id and position) both sides have 167 entities and the same unmatched trident, armor stand and arrow pairs, and no field differs on wind charges, breeze wind charges, splash or lingering potions. Without the UUID change, the potions' random UUIDs were 4 differing fields. Remaining diffs of vanilla -> Horizon -> vanilla vs the control: 59 fields, none on these kinds (mob attributes, random mob fields; same as on main).

Tests (entity_nbt): wind_charges_in_flight_are_saved_and_read_back, a_lingering_potion_keeps_its_type_whatever_item_it_flies_as, a_summoned_painting_or_frame_has_no_block_pos_and_sits_at_its_position, and the updated kinds list in thrown_item_projectiles_round_trip_their_flight_item_and_owner. All four fail on main and pass here (36 passed).

Harnesses

Run on this branch with DISPLAY=:0 HORIZON_E2E_HEADLESS=1:

  • tools/test_save_roundtrip_parity.py: ok, 0 unexplained differences. (A first run on this branch reported 2 unexplained differences, a spawner block entity's Delay in the vanilla view; the rerun on this branch and a run on main both report 0. The spawner is untouched by this PR, so this reads as a timing flake; not investigated further.)
  • tools/test_world_reopen_parity.py: PASS (4 minecarts after each of 3 reopens).
  • tools/test_server_entities_parity.py: 31 entities identical.
  • tools/pr_ready.py --quick: all checks pass, 2085 tests passed; the 258 affected parity harnesses are left to CI.

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 0ac35dac7, 11 min 9 s)

Check Result
Scope ✅ 6 files, +137 −41
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (35 s)
rustfmt ✅ (8 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 ✅ (2 min 16 s)
tests: horizon-client, horizon-client-lib ✅ 2106 passed (7 min 37 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ✅ (15 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 258 affected, to run in CI (--quick): armor_stand_turtle_egg, arrow, arrow_wind_charge, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, boat_authority and 246 more
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/7177 **Author:** [@HrafnaValkyrja](https://github.com/HrafnaValkyrja) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/save-missing-kinds` --- ### 📝 Commits (3) - [`4d83f58`](https://github.com/horizon-rust/horizon/commit/4d83f58262c8caaf75a694dd70e566d682737efe) Save wind charges, keep a lingering potion's type, read block-attached entities summoned without block_pos - [`f006d06`](https://github.com/horizon-rust/horizon/commit/f006d0635b207976f5bb53132a0527a2d5c7162f) Keep a splash or lingering potion's UUID through a save - [`15fc1ce`](https://github.com/horizon-rust/horizon/commit/15fc1ce2fb3846179ec1a58c15109268c0247012) Merge remote-tracking branch 'origin/main' into fix/save-missing-kinds ### 📊 Changes **6 files changed** (+137 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+115 -23) 📝 `crates/horizon-client/src/game/creatures.rs` (+1 -1) 📝 `crates/horizon-client/src/game/lan_entities.rs` (+1 -1) 📝 `crates/horizon-client/src/game/persist.rs` (+2 -0) 📝 `crates/horizon-client/src/mobs/witch.rs` (+2 -2) 📝 `crates/horizon-client/src/projectiles.rs` (+16 -14) </details> ### 📄 Description > 🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself. ## What and why A vanilla 26.3 world loaded in Horizon and saved lost entities (found by the round trip of #6545). This fixes the ones that are real losses: - **Wind charges and breeze wind charges were not saved.** `entity_nbt::saved_with_chunk` decides whether a projectile is written; it left out `WindCharge` and `BreezeWindCharge` although `fireball_to_nbt` writes them and `fireball_from_nbt` reads them, so they were lost on save (4 of 170). `saved_with_chunk` is now an exhaustive match with no wildcard: a new `ProjectileKind` does not compile until it says whether it is saved. An old test asserted that wind charges are not saved; it now asserts they are. - **A lingering potion came back as a splash potion.** `ProjectileKind::Potion` took its entity type from the `Item` stack, so a `lingering_potion` entity with a splash potion `Item` was written as `splash_potion` (2 of 170). The variant now carries whether its entity type is lingering (`ProjectileKind::potion(stack)` sets it from the item for thrown ones; loading uses the entity id). - **Splash and lingering potions got a random UUID on each save** (the saved UUID was not remembered). They are now in the same memory as the other throwables (`persist.rs`, 2 lines). - **`/summon painting` and `/summon item_frame` were refused.** `painting_from_nbt` and `item_frame_from_nbt` required `block_pos`; vanilla (`BlockAttachedEntity.readAdditionalSaveData`) reads it as optional, and `setPos` puts the block at the summon position. Not changed: `firework_rocket` with `LifeTime:0` and `ominous_item_spawner` with `spawn_item_after_ticks:0` are lost in the round trip too, but vanilla loses them on a plain vanilla reload as well (measured), so that is parity. In-flight projectiles do persist in vanilla: `Entity.shouldBeSaved` is true unless the entity was removed with a reason that does not save, and neither `Projectile`, `FireworkRocketEntity` nor `OminousItemSpawner` overrides it or `isAlwaysTicking` (bytecode of 26.3 `server-game.jar`). Overlap with #6545 (slice 10, moving the save loops): this PR touches no loop. `saved_with_chunk` is called from the projectile loop in `entity_chunks`; if that loop becomes `Entity::save_nbt`, the same function is the filter. The 2-line UUID change is in `spawn_loaded_entities`, which slice 10 leaves alone. Fixes #7176 ## 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 26.3 `server.jar` as the oracle: `BlockAttachedEntity.readAdditionalSaveData` (`block_pos` read with `orElse(null)`), `Entity.shouldBeSaved`, the entity ids `minecraft:wind_charge`, `minecraft:breeze_wind_charge`, `minecraft:lingering_potion` (own type, any `Item`). ## Proof Round trip with the 170-entity world of #6545 (vanilla summons, 2 groups), entity region files read back, entities matched by id and position: | | entities after | wind | breeze | lingering | splash | paintings | frames | |---|---|---|---|---|---|---|---| | vanilla original | 170 | 2 | 2 | 2 | 2 | 2 | 2 | | vanilla loaded and saved again (control) | 168 | 2 | 2 | 2 | 2 | 2 | 2 | | main: vanilla -> Horizon -> vanilla | 165 | 0 | 0 | 0 | 4 | 2 | 2 | | this PR: vanilla -> Horizon -> vanilla | 169 | 2 | 2 | 2 | 2 | 2 | 2 | The control loses the rocket and the spawner. Main loses those and the wind charges and lingering potions. This PR keeps all of them; the totals differ from the control by the eye of ender entities, which vanilla removes after 80 ticks (a timing effect of the harness, noted in #6545). In the field diff against the control (matched by id and position) both sides have 167 entities and the same unmatched trident, armor stand and arrow pairs, and no field differs on wind charges, breeze wind charges, splash or lingering potions. Without the UUID change, the potions' random UUIDs were 4 differing fields. Remaining diffs of vanilla -> Horizon -> vanilla vs the control: 59 fields, none on these kinds (mob attributes, random mob fields; same as on main). Tests (`entity_nbt`): `wind_charges_in_flight_are_saved_and_read_back`, `a_lingering_potion_keeps_its_type_whatever_item_it_flies_as`, `a_summoned_painting_or_frame_has_no_block_pos_and_sits_at_its_position`, and the updated kinds list in `thrown_item_projectiles_round_trip_their_flight_item_and_owner`. All four fail on main and pass here (36 passed). ## Harnesses Run on this branch with `DISPLAY=:0 HORIZON_E2E_HEADLESS=1`: - `tools/test_save_roundtrip_parity.py`: ok, 0 unexplained differences. (A first run on this branch reported 2 unexplained differences, a spawner block entity's `Delay` in the vanilla view; the rerun on this branch and a run on main both report 0. The spawner is untouched by this PR, so this reads as a timing flake; not investigated further.) - `tools/test_world_reopen_parity.py`: PASS (4 minecarts after each of 3 reopens). - `tools/test_server_entities_parity.py`: 31 entities identical. - `tools/pr_ready.py --quick`: all checks pass, 2085 tests passed; the 258 affected parity harnesses are left to CI. 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 0ac35dac7, 11 min 9 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +137 −41 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (35 s) | | rustfmt | ✅ (8 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 | ✅ (2 min 16 s) | | tests: horizon-client, horizon-client-lib | ✅ 2106 passed (7 min 37 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (15 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 258 affected, to run in CI (--quick): armor_stand_turtle_egg, arrow, arrow_wind_charge, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, boat_authority and 246 more | | 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:38:53 +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#7395
No description provided.