[PR #55] [MERGED] Worldgen: decorate in vanilla's chunk order; keep worldgen's scheduled ticks #2302

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

📋 Pull Request Information

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

Base: main ← Head: worldgen-trees


📝 Commits (7)

  • 897ca2a Worldgen shape updates schedule their ticks in the proto chunks
  • 2c8de2b chunk_generation: compare scheduled ticks; HORIZON_ORDER decoration order
  • 4c4e579 Generated chunks keep the ticks their features scheduled
  • 147ea66 Decorate chunks around the player in vanilla's order
  • 317da28 Structure pieces schedule the fluid ticks of the fluids they place
  • 2c57fcc decorated_region: compare fully decorated regions decorated in vanilla's order
  • 069acd9 Streaming: wait only for lower-ranked chunks that can be decorated

📊 Changes

12 files changed (+739 additions, -47 deletions)

View changed files

📝 crates/horizon-client/src/streaming.rs (+74 -9)
📝 crates/horizon-client/src/vanillagen.rs (+41 -0)
📝 crates/horizon-world/examples/chunk_dump.rs (+86 -27)
📝 crates/horizon-world/src/level/ticks.rs (+31 -0)
📝 crates/horizon-world/src/worldgen.rs (+1 -0)
➕ crates/horizon-world/src/worldgen/decoration_order.rs (+266 -0)
📝 crates/horizon-world/src/worldgen/generator_decoration.rs (+34 -6)
📝 crates/horizon-world/src/worldgen/structure/legacy.rs (+16 -1)
📝 docs/world-generation.md (+22 -2)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaChunkGenerationOracle.java (+20 -1)
📝 tools/test_chunk_generation_parity.py (+9 -1)
➕ tools/test_decorated_region_parity.py (+139 -0)

📄 Description

Two reports of fully generated regions differing from vanilla on seed 1891623539983467248 while terrain matched: Cosmic's taiga trees at 204 108 -239, and Ludovic's stronghold (rooms missing around the portal room), sculk around a lava lake and an amethyst geode at 4870 -22 401.

Root causes

  1. Decoration order (the main one, both reports). Biome decoration is order dependent: a chunk's features write into its eight neighbours, so a tree, ore blob, sculk patch or geode placed first changes where the next chunk's features fit and how many random draws they take, and a neighbour's geode placed after a stronghold piece cuts through it. The row-major harness matched vanilla exactly, but the game's streamer decorated whichever chunk had its protos ready, spread over non-overlapping regions for parallelism. Measured against a real vanilla server (Horizon joining it as the player, teleporting to the spot, JFR minecraft.ChunkGeneration events for vanilla's order), the game swapped 45% of the overlapping chunk pairs; two vanilla runs swap 6%. Fed vanilla's recorded order, the oracle reproduces the vanilla server's world exactly, so order is the whole story. worldgen::decoration_order now replays vanilla's chunk scheduler for a standing player (loading tickets ring by ring in fastutil hash order, four in flight, FULL tasks decorating their 3x3 squares x-outer by ticket level, INITIALIZE_LIGHT tasks themselves); its first wave and its count (529 chunks at view distance 8) match vanilla's trace, and it swaps as many pairs as a second vanilla run does. The streamer decorates a chunk only once no lower-ranked chunk within two of it is waiting, so distant chunks still decorate in parallel.
  2. Shape-update ticks dropped. StructureTemplate.updateShapeAtEdge (after every tree) runs updateShape, where LeavesBlock schedules a tick to re-measure its distance; Horizon ran it against a throwaway scheduler. Leaves where trees overlap kept their own tree's distance (one more than vanilla's, ~3,300 leaves around the taiga spot).
  3. Proto ticks not carried into live chunks. VanillaTerrain::finish dropped the proto chunk's block and fluid ticks; vanilla's LevelChunk takes them over.
  4. Structure pieces' fluid ticks. StructurePiece.placeBlock schedules a tick for each fluid it places (the portal room's lava); the port treated it as a no-op.

Results

  • New harness tools/test_decorated_region_parity.py: a 13x13-chunk area per site decorated on both sides in vanilla's player order, comparing every block state, quart biome, block entity and scheduled tick (the whole-chunk harness now compares ticks too): both report sites, 11 tree-heavy biomes (taiga, old-growth spruce taiga, snowy taiga, dark forest, birch forest, jungle, bamboo jungle, savanna, cherry grove, mangrove swamp, pale garden) and the nearest mineshaft, village, ancient city and trial chambers on two seeds. 21 sites, 3,549 chunks (~530k scheduled ticks), 0 differences.

  • In game vs a real vanilla server around the taiga spot (25 chunks, ignoring live ticks): ~9,000 differing blocks before, ~1,000 after; two vanilla runs differ by ~220 (vanilla's order depends on async timing too).

  • Stronghold area (81 chunks): no stronghold, sculk or geode differences left; the remaining ~1,150 ore-blob blocks are fewer than two vanilla servers differ by there (~1,800).

  • Regressions: every harness whose inputs changed (261, then the 40 the last streaming commit touched; Mac mini + desktop): all pass, including chunk_generation with its new scheduled-tick comparison. tools/gate.py --no-parity (fmt, clippy, Rust and Python tests) passes.

  • In game (vscreen, lavapipe): the taiga spot and the stronghold view from the report render the same as the vanilla server's world opened in the same client. Render distances 2, 5 and 12 load and keep loading while flying (the streamer only waits on lower-ranked chunks that can actually be decorated).

Not exact to the block in game: vanilla's own order depends on worldgen thread timing (its first tasks around a teleport vary between runs), which a deterministic model can't reproduce; the residual is at the scale of vanilla against itself. Unrelated thing noticed: Horizon's world spawn on this seed is at -48 -48, vanilla's at 152 145.

🤖 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/55 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `worldgen-trees` --- ### 📝 Commits (7) - [`897ca2a`](https://github.com/horizon-rust/horizon/commit/897ca2aa5efae4b2d1325a0d3ac96947ca84a4ba) Worldgen shape updates schedule their ticks in the proto chunks - [`2c8de2b`](https://github.com/horizon-rust/horizon/commit/2c8de2b015c91cbd13006a0dc3b94a98765a7cbc) chunk_generation: compare scheduled ticks; HORIZON_ORDER decoration order - [`4c4e579`](https://github.com/horizon-rust/horizon/commit/4c4e579d3f9cc7e6cf78f9ba535b590d583a14ec) Generated chunks keep the ticks their features scheduled - [`147ea66`](https://github.com/horizon-rust/horizon/commit/147ea6661fe327c3175ed34bb13354822b4acc41) Decorate chunks around the player in vanilla's order - [`317da28`](https://github.com/horizon-rust/horizon/commit/317da28481d868f989c700524fffbf18dc6ce6ab) Structure pieces schedule the fluid ticks of the fluids they place - [`2c57fcc`](https://github.com/horizon-rust/horizon/commit/2c57fcc09ffbbad65a85f8c09e8388f24b3c212c) decorated_region: compare fully decorated regions decorated in vanilla's order - [`069acd9`](https://github.com/horizon-rust/horizon/commit/069acd9aba710dc5908427b4bdab061d126ba3e4) Streaming: wait only for lower-ranked chunks that can be decorated ### 📊 Changes **12 files changed** (+739 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/streaming.rs` (+74 -9) 📝 `crates/horizon-client/src/vanillagen.rs` (+41 -0) 📝 `crates/horizon-world/examples/chunk_dump.rs` (+86 -27) 📝 `crates/horizon-world/src/level/ticks.rs` (+31 -0) 📝 `crates/horizon-world/src/worldgen.rs` (+1 -0) ➕ `crates/horizon-world/src/worldgen/decoration_order.rs` (+266 -0) 📝 `crates/horizon-world/src/worldgen/generator_decoration.rs` (+34 -6) 📝 `crates/horizon-world/src/worldgen/structure/legacy.rs` (+16 -1) 📝 `docs/world-generation.md` (+22 -2) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaChunkGenerationOracle.java` (+20 -1) 📝 `tools/test_chunk_generation_parity.py` (+9 -1) ➕ `tools/test_decorated_region_parity.py` (+139 -0) </details> ### 📄 Description Two reports of fully generated regions differing from vanilla on seed 1891623539983467248 while terrain matched: Cosmic's taiga trees at 204 108 -239, and Ludovic's stronghold (rooms missing around the portal room), sculk around a lava lake and an amethyst geode at 4870 -22 401. ## Root causes 1. **Decoration order** (the main one, both reports). Biome decoration is order dependent: a chunk's features write into its eight neighbours, so a tree, ore blob, sculk patch or geode placed first changes where the next chunk's features fit and how many random draws they take, and a neighbour's geode placed after a stronghold piece cuts through it. The row-major harness matched vanilla exactly, but the game's streamer decorated whichever chunk had its protos ready, spread over non-overlapping regions for parallelism. Measured against a real vanilla server (Horizon joining it as the player, teleporting to the spot, JFR `minecraft.ChunkGeneration` events for vanilla's order), the game swapped 45% of the overlapping chunk pairs; two vanilla runs swap 6%. Fed vanilla's recorded order, the oracle reproduces the vanilla server's world exactly, so order is the whole story. `worldgen::decoration_order` now replays vanilla's chunk scheduler for a standing player (loading tickets ring by ring in fastutil hash order, four in flight, FULL tasks decorating their 3x3 squares x-outer by ticket level, INITIALIZE_LIGHT tasks themselves); its first wave and its count (529 chunks at view distance 8) match vanilla's trace, and it swaps as many pairs as a second vanilla run does. The streamer decorates a chunk only once no lower-ranked chunk within two of it is waiting, so distant chunks still decorate in parallel. 2. **Shape-update ticks dropped.** `StructureTemplate.updateShapeAtEdge` (after every tree) runs `updateShape`, where `LeavesBlock` schedules a tick to re-measure its distance; Horizon ran it against a throwaway scheduler. Leaves where trees overlap kept their own tree's distance (one more than vanilla's, ~3,300 leaves around the taiga spot). 3. **Proto ticks not carried into live chunks.** `VanillaTerrain::finish` dropped the proto chunk's block and fluid ticks; vanilla's `LevelChunk` takes them over. 4. **Structure pieces' fluid ticks.** `StructurePiece.placeBlock` schedules a tick for each fluid it places (the portal room's lava); the port treated it as a no-op. ## Results - New harness `tools/test_decorated_region_parity.py`: a 13x13-chunk area per site decorated on both sides in vanilla's player order, comparing every block state, quart biome, block entity and **scheduled tick** (the whole-chunk harness now compares ticks too): both report sites, 11 tree-heavy biomes (taiga, old-growth spruce taiga, snowy taiga, dark forest, birch forest, jungle, bamboo jungle, savanna, cherry grove, mangrove swamp, pale garden) and the nearest mineshaft, village, ancient city and trial chambers on two seeds. **21 sites, 3,549 chunks (~530k scheduled ticks), 0 differences.** - In game vs a real vanilla server around the taiga spot (25 chunks, ignoring live ticks): ~9,000 differing blocks before, ~1,000 after; two vanilla runs differ by ~220 (vanilla's order depends on async timing too). - Stronghold area (81 chunks): no stronghold, sculk or geode differences left; the remaining ~1,150 ore-blob blocks are fewer than two vanilla servers differ by there (~1,800). - Regressions: every harness whose inputs changed (261, then the 40 the last streaming commit touched; Mac mini + desktop): all pass, including `chunk_generation` with its new scheduled-tick comparison. `tools/gate.py --no-parity` (fmt, clippy, Rust and Python tests) passes. - In game (vscreen, lavapipe): the taiga spot and the stronghold view from the report render the same as the vanilla server's world opened in the same client. Render distances 2, 5 and 12 load and keep loading while flying (the streamer only waits on lower-ranked chunks that can actually be decorated). Not exact to the block in game: vanilla's own order depends on worldgen thread timing (its first tasks around a teleport vary between runs), which a deterministic model can't reproduce; the residual is at the scale of vanilla against itself. Unrelated thing noticed: Horizon's world spawn on this seed is at -48 -48, vanilla's at 152 145. 🤖 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:54:46 +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#2302
No description provided.