[PR #284] [MERGED] Save every generated chunk and decorated proto chunks, as vanilla does (#249) #2455

Closed
opened 2026-11-02 15:56:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/284
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: fix/bastion-chunks


📝 Commits (1)

  • 1c3fd6e Save every generated chunk and the proto chunks decoration wrote to (#249)

📊 Changes

9 files changed (+891 additions, -150 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+13 -2)
📝 crates/horizon-client/src/save.rs (+179 -6)
📝 crates/horizon-client/src/streaming.rs (+171 -65)
📝 crates/horizon-client/src/vanillagen.rs (+197 -72)
➕ crates/horizon-client/tests/generation_saves.rs (+303 -0)
📝 crates/horizon-world/src/worldgen/generator.rs (+2 -1)
📝 crates/horizon-world/src/worldgen/terrain.rs (+4 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaStructurePlacementOracle.java (+4 -0)
📝 tools/test_chunk_generation_parity.py (+18 -4)

📄 Description

Fixes #249. Stacked on #274 (#228); review only the top commit.

What

Horizon now saves chunks the way vanilla does:

  • Every generated chunk is saved, not only modified ones.
  • Proto chunks that decoration (features and structure pieces) wrote into are saved with their status and restored when they load again.

Why

Bastion generation itself matches vanilla. On the issue's seed (-1860902098141295193, Nether), the structure start, its pieces and all 20 chunks the bastion covers are identical to vanilla 26.3 (harness below). The missing chunks came from streaming:

  • Unmodified final chunks were never saved. Proto chunks, which hold the pieces neighbouring decorations had written into them, were dropped when the player moved away.
  • When the area came back, those chunks were generated again without the neighbours' writes. The chunks next to an already-finished neighbour also skipped their own decoration. Bastion pieces crossing those chunks were gone (in game: chunk 3,6 went from 610 bastion blocks to 0, chunk 3,8 from 520 to 0).
  • Vanilla keeps every chunk, protos included, with its status, so this never happens there.

Changes:

  • save.rs: encode_proto / decode_proto write and read a proto chunk with its Status, PostProcessing, block entities and entities. Persistent restores saved protos and saves chunks that are finished after the player has left.
  • vanillagen.rs: saved_proto / restore_proto rebuild the ProtoChunk exactly: blocks, decoration stage, heightmaps, ticks, post-processing, block entities and entities.
  • streaming.rs: tracks which protos decoration wrote into, saves them when they are dropped and on world save, and waits for in-flight decoration and finish jobs before an explicit save. Newly finished chunks are marked modified so they are saved.
  • game.rs: autosave no longer waits for the writer thread, so saving every chunk causes no hitch. save, save-all, quit and dimension changes still flush.
  • VanillaStructurePlacementOracle.java: gives the proxy level environmentAttributes(). Nether lava needs it, and the oracle used to fail in the Nether.

How tested

  • tools/test_chunk_generation_parity.py gains a fixed regression case: the #249 bastion, 20 chunks (rect -1,6 to 3,9 in the Nether). It runs by default. Result: 0 differing chunks, 0 blocks, 0 biome cells, 0 block entities.
  • New crates/horizon-client/tests/generation_saves.rs:
    • chunks_left_behind_keep_their_decoration: walks away in steps, teleports, comes back, saves and restarts. It checks that each of more than 200 columns is finished exactly once, decorated, holding each of its nine neighbours' decorations exactly once.
      • Fails without saving dropped protos ("must hold each neighbour's decoration exactly once").
      • Fails without saving fresh chunks ("was generated again").
    • saved_proto_chunks_restore_exactly: on the bastion region, a decorated 3x3 is saved, restored and finished. It is compared block for block (384 levels), plus block entities, post-processing, entities, structure references and ticks. It fails without the restore.
  • In game on the Mac mini, the issue's world: after walking away and back, then quitting and reopening, every bastion chunk equals a freshly generated world's.
  • Parity (tools/parity.py on the Mac mini): chunk_generation (fresh oracle), chunk_stage, chunk_status, decorated_region, decoration_region, feature_region, retrogen_chunk and structure_density pass. save_roundtrip needs vscreen (Linux desktop only), so it is left to CI's parity job.
  • Self-check:
cargo fmt --all -- --check                            OK
cargo clippy --workspace --all-targets -D warnings    exit 0
cargo test -p horizon-client -p horizon-world         806 passed, 0 failed (with #274 below it)

Needs Ludovic

  • Merge #274 first. With every chunk saved, most chunks load with their light, which is exactly the case #228/#274 fixes.
  • Saves grow. Every generated chunk now lands in the region files, as in vanilla: more disk and IO than before.
  • Old saves. Worlds saved before this change keep the old fallback (a chunk next to a finished neighbour skips decoration) for chunks generated earlier. New areas are exact.

🤖 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/284 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/bastion-chunks` --- ### 📝 Commits (1) - [`1c3fd6e`](https://github.com/horizon-rust/horizon/commit/1c3fd6e23ce182e9f0f4de6a6e1d24a94384fca5) Save every generated chunk and the proto chunks decoration wrote to (#249) ### 📊 Changes **9 files changed** (+891 additions, -150 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+13 -2) 📝 `crates/horizon-client/src/save.rs` (+179 -6) 📝 `crates/horizon-client/src/streaming.rs` (+171 -65) 📝 `crates/horizon-client/src/vanillagen.rs` (+197 -72) ➕ `crates/horizon-client/tests/generation_saves.rs` (+303 -0) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+2 -1) 📝 `crates/horizon-world/src/worldgen/terrain.rs` (+4 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaStructurePlacementOracle.java` (+4 -0) 📝 `tools/test_chunk_generation_parity.py` (+18 -4) </details> ### 📄 Description Fixes #249. Stacked on #274 (#228); review only the top commit. ## What Horizon now saves chunks the way vanilla does: - Every generated chunk is saved, not only modified ones. - Proto chunks that decoration (features and structure pieces) wrote into are saved with their status and restored when they load again. ## Why Bastion generation itself matches vanilla. On the issue's seed (-1860902098141295193, Nether), the structure start, its pieces and all 20 chunks the bastion covers are identical to vanilla 26.3 (harness below). The missing chunks came from streaming: - Unmodified final chunks were never saved. Proto chunks, which hold the pieces neighbouring decorations had written into them, were dropped when the player moved away. - When the area came back, those chunks were generated again without the neighbours' writes. The chunks next to an already-finished neighbour also skipped their own decoration. Bastion pieces crossing those chunks were gone (in game: chunk 3,6 went from 610 bastion blocks to 0, chunk 3,8 from 520 to 0). - Vanilla keeps every chunk, protos included, with its status, so this never happens there. Changes: - `save.rs`: `encode_proto` / `decode_proto` write and read a proto chunk with its `Status`, `PostProcessing`, block entities and entities. `Persistent` restores saved protos and saves chunks that are finished after the player has left. - `vanillagen.rs`: `saved_proto` / `restore_proto` rebuild the `ProtoChunk` exactly: blocks, decoration stage, heightmaps, ticks, post-processing, block entities and entities. - `streaming.rs`: tracks which protos decoration wrote into, saves them when they are dropped and on world save, and waits for in-flight decoration and finish jobs before an explicit save. Newly finished chunks are marked modified so they are saved. - `game.rs`: autosave no longer waits for the writer thread, so saving every chunk causes no hitch. `save`, `save-all`, quit and dimension changes still flush. - `VanillaStructurePlacementOracle.java`: gives the proxy level `environmentAttributes()`. Nether lava needs it, and the oracle used to fail in the Nether. ## How tested - `tools/test_chunk_generation_parity.py` gains a fixed regression case: the #249 bastion, 20 chunks (rect -1,6 to 3,9 in the Nether). It runs by default. Result: 0 differing chunks, 0 blocks, 0 biome cells, 0 block entities. - New `crates/horizon-client/tests/generation_saves.rs`: - `chunks_left_behind_keep_their_decoration`: walks away in steps, teleports, comes back, saves and restarts. It checks that each of more than 200 columns is finished exactly once, decorated, holding each of its nine neighbours' decorations exactly once. - Fails without saving dropped protos ("must hold each neighbour's decoration exactly once"). - Fails without saving fresh chunks ("was generated again"). - `saved_proto_chunks_restore_exactly`: on the bastion region, a decorated 3x3 is saved, restored and finished. It is compared block for block (384 levels), plus block entities, post-processing, entities, structure references and ticks. It fails without the restore. - In game on the Mac mini, the issue's world: after walking away and back, then quitting and reopening, every bastion chunk equals a freshly generated world's. - Parity (`tools/parity.py` on the Mac mini): chunk_generation (fresh oracle), chunk_stage, chunk_status, decorated_region, decoration_region, feature_region, retrogen_chunk and structure_density pass. save_roundtrip needs `vscreen` (Linux desktop only), so it is left to CI's `parity` job. - Self-check: ``` cargo fmt --all -- --check OK cargo clippy --workspace --all-targets -D warnings exit 0 cargo test -p horizon-client -p horizon-world 806 passed, 0 failed (with #274 below it) ``` ## Needs Ludovic - **Merge #274 first.** With every chunk saved, most chunks load with their light, which is exactly the case #228/#274 fixes. - **Saves grow.** Every generated chunk now lands in the region files, as in vanilla: more disk and IO than before. - **Old saves.** Worlds saved before this change keep the old fallback (a chunk next to a finished neighbour skips decoration) for chunks generated earlier. New areas are exact. 🤖 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>
bsakaguchi 2026-11-02 15:56:18 +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#2455
No description provided.