[PR #4420] [MERGED] Chunks around those an older version generated blend with them (Blender and BlendingData) #5617

Closed
opened 2026-11-03 05:13:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4420
Author: @xFedeT
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: feat/blending-old-chunks


📝 Commits (10+)

  • 83767f8 Blender and BlendingData: terrain, biomes and carving next to old chunks
  • a58d441 Chunks an older version saved: the game reads them for Blender.of
  • 5b5503f Merge main into feat/blending-old-chunks
  • 5d10385 Chunks beside old ones are decorated, their features spilling into the old chunks
  • db899c8 Merge remote-tracking branch 'origin/main' into feat/blending-old-chunks
  • 8e75d8a Old chunks: one scan per region, the other workers wait for it
  • 471e559 Decoration into an old chunk carries the block entities it made
  • 04b63e8 Old chunks: /locate and maps see the starts the chunk saved
  • 01c5be5 Merge remote-tracking branch 'origin/main' into feat/blending-old-chunks
  • 085561f Decoration into a final chunk waits for the one writing into it

📊 Changes

20 files changed (+2608 additions, -56 deletions)

View changed files

📝 crates/horizon-client-render/src/streaming.rs (+131 -17)
➕ crates/horizon-client/examples/old_world_fixture.rs (+80 -0)
📝 crates/horizon-client/src/game/world_loading.rs (+9 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/mod_content_tests.rs (+165 -0)
➕ crates/horizon-client/src/old_world.rs (+299 -0)
📝 crates/horizon-client/src/save.rs (+54 -0)
📝 crates/horizon-client/src/vanillagen.rs (+66 -0)
📝 crates/horizon-client/tests/generation_saves.rs (+52 -0)
📝 crates/horizon-world/examples/probe/chunk_dump.rs (+132 -2)
📝 crates/horizon-world/src/worldgen.rs (+1 -0)
➕ crates/horizon-world/src/worldgen/blending.rs (+1031 -0)
📝 crates/horizon-world/src/worldgen/generator.rs (+171 -14)
📝 crates/horizon-world/src/worldgen/generator_structures.rs (+128 -0)
📝 crates/horizon-world/src/worldgen/structure/start.rs (+10 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaChunkGenerationOracle.java (+71 -5)
➕ tools/old_world_e2e.py (+114 -0)
📝 tools/port_map/classes-05.tsv (+1 -1)
📝 tools/port_map/levelgen-1.tsv (+17 -17)
➕ tools/test_blending_parity.py (+75 -0)

📄 Description

🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally.

Refs #3517

What and why

A world upgraded from before 1.18 keeps its old chunks. Vanilla generates the new chunks around them with Blender.of(region): the terrain height and density, the biomes and the carving of a new chunk blend into the old terrain for up to 7 chunks, so there is no wall where the two meet. Horizon had no Blender: new chunks next to old ones met them in a cliff (datafix already marks old chunks with blending_data, but nothing used it).

This ports Blender and BlendingData:

  • worldgen/blending.rs (horizon-world): BlendingData (the saved min_section/max_section/heights; the density, height and biome of the border columns of an old chunk, as calculateData reads them), Blender.of, blendOffsetAndFactor (the blend_alpha/blend_offset fields), blendDensity, blendBiome and the carving filter. Vanilla adds weighted sums over a fastutil Long2ObjectOpenHashMap in its entry order, and a sum's last bits depend on it, so the maps walk their entries in that order (OpenMap).
  • The generator takes an OldWorld (the chunks an older version saved): the biome chunks, the density graph (WorldField::BlendAlpha/BlendOffset and the blend_density hook that already existed) and the carving mask use the chunk's Blender; an old chunk keeps the biomes it was saved with.
  • old_world.rs (horizon-client): which saved chunks are old (IOWorker.isOldChunk: DataVersion below 4997 or blending_data, scanned per region), their blending_data, the border columns from the decoded chunk and the biomes they keep. BlendingData.isGround and SURFACE_BLOCKS come from the block collision table (GeneratorData::is_old_chunk_ground).
  • HORIZON_DISABLE_BLENDING turns it off, as vanilla's SharedConstants.DEBUG_DISABLE_BLENDING.

The starts an old chunk saved (structures.starts) come back with their pieces, as StructureStart.loadStaticStart loads them, so the neighbours place the parts that cross the border and the Beardifier sees them: a jigsaw start (villages, pillager outposts, bastions, ancient cities, trial chambers, trail ruins) is loaded from its saved Children (PoolPiece::from_saved). The pieces of the other structures (mineshafts, fortresses, strongholds, monuments, temples, shipwrecks, end cities, ruined portals) have no NBT loader yet: such a start is the generator's own when that has the same name and the same pieces' box (the same layout from the same seed), else it is the name and the box alone, which /locate and maps find but nothing places.

Not in this PR: Blender.generateBorderTicks (leaves and fluids at the old/new border are not marked for post-processing yet), and the below-zero retrogen of chunks that are not full.

Proof

Against vanilla, block for block. python3 tools/test_blending_parity.py: VanillaChunkGenerationOracle (new HORIZON_OLD_CHUNKS) makes chunks of another seed count as saved by an older version and generates the target chunks around them with the real Blender.of(region); the chunk_dump probe does the same. 185 chunks in four cases (a wall of old chunks, a single one, a block of four with another seed, far from the origin): 0 differing blocks, 0 differing biome cells. Without blending the same chunks differ by tens of thousands of blocks.

In the game. python3 tools/old_world_e2e.py: 136 chunks of a seed-111 world are put into a seed-4242 world as old chunks (old_world_fixture), west of x = 0; the game generates the east. The same world is opened with blending (this PR) and with HORIZON_DISABLE_BLENDING. Real screenshots of the running game, same camera:

Without blending With blending
From above the new side, looking west
Along the border

Without it, the new terrain stops at a stone wall of about 40 blocks where the old chunks begin. With it, the land runs on from the old chunks and settles to the new terrain's height. (The two games' windows had different sizes, so the screenshots differ in resolution; the camera positions are the same.)

pr_ready --quick: fmt, clippy, 1257 tests and 480 python tests pass; parity harnesses left to CI. This is over 500 lines because the port is one piece (the module, its wiring, the saved-chunk reader and the proofs); the two commits are the generator side and the client side.

🤖 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/4420 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/blending-old-chunks` --- ### 📝 Commits (10+) - [`83767f8`](https://github.com/horizon-rust/horizon/commit/83767f883ec844c352770fea9ff9ee5e207ff412) Blender and BlendingData: terrain, biomes and carving next to old chunks - [`a58d441`](https://github.com/horizon-rust/horizon/commit/a58d441ce92ab7f471ef4d8aed1757157cd22693) Chunks an older version saved: the game reads them for Blender.of - [`5b5503f`](https://github.com/horizon-rust/horizon/commit/5b5503fce05221e22ed073034e84338029261197) Merge main into feat/blending-old-chunks - [`5d10385`](https://github.com/horizon-rust/horizon/commit/5d1038557f26b452f1c07edbcbed2a57427ca22f) Chunks beside old ones are decorated, their features spilling into the old chunks - [`db899c8`](https://github.com/horizon-rust/horizon/commit/db899c8276c89f7311240f3935c52506528734b1) Merge remote-tracking branch 'origin/main' into feat/blending-old-chunks - [`8e75d8a`](https://github.com/horizon-rust/horizon/commit/8e75d8ac19803ecae58d504ddbfc86360ff5fe97) Old chunks: one scan per region, the other workers wait for it - [`471e559`](https://github.com/horizon-rust/horizon/commit/471e559ae356908ac50df6701261137135ac0459) Decoration into an old chunk carries the block entities it made - [`04b63e8`](https://github.com/horizon-rust/horizon/commit/04b63e8553e8fcb644dfc16de4c90bc44220d150) Old chunks: /locate and maps see the starts the chunk saved - [`01c5be5`](https://github.com/horizon-rust/horizon/commit/01c5be5f350e68d6064cfd8fb58453b592846101) Merge remote-tracking branch 'origin/main' into feat/blending-old-chunks - [`085561f`](https://github.com/horizon-rust/horizon/commit/085561fcecdfec02c004592831d45cb41d23881f) Decoration into a final chunk waits for the one writing into it ### 📊 Changes **20 files changed** (+2608 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/streaming.rs` (+131 -17) ➕ `crates/horizon-client/examples/old_world_fixture.rs` (+80 -0) 📝 `crates/horizon-client/src/game/world_loading.rs` (+9 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+165 -0) ➕ `crates/horizon-client/src/old_world.rs` (+299 -0) 📝 `crates/horizon-client/src/save.rs` (+54 -0) 📝 `crates/horizon-client/src/vanillagen.rs` (+66 -0) 📝 `crates/horizon-client/tests/generation_saves.rs` (+52 -0) 📝 `crates/horizon-world/examples/probe/chunk_dump.rs` (+132 -2) 📝 `crates/horizon-world/src/worldgen.rs` (+1 -0) ➕ `crates/horizon-world/src/worldgen/blending.rs` (+1031 -0) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+171 -14) 📝 `crates/horizon-world/src/worldgen/generator_structures.rs` (+128 -0) 📝 `crates/horizon-world/src/worldgen/structure/start.rs` (+10 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaChunkGenerationOracle.java` (+71 -5) ➕ `tools/old_world_e2e.py` (+114 -0) 📝 `tools/port_map/classes-05.tsv` (+1 -1) 📝 `tools/port_map/levelgen-1.tsv` (+17 -17) ➕ `tools/test_blending_parity.py` (+75 -0) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. Refs #3517 ## What and why A world upgraded from before 1.18 keeps its old chunks. Vanilla generates the new chunks around them with `Blender.of(region)`: the terrain height and density, the biomes and the carving of a new chunk blend into the old terrain for up to 7 chunks, so there is no wall where the two meet. Horizon had no `Blender`: new chunks next to old ones met them in a cliff (`datafix` already marks old chunks with `blending_data`, but nothing used it). This ports `Blender` and `BlendingData`: - `worldgen/blending.rs` (horizon-world): `BlendingData` (the saved `min_section`/`max_section`/`heights`; the density, height and biome of the border columns of an old chunk, as `calculateData` reads them), `Blender.of`, `blendOffsetAndFactor` (the `blend_alpha`/`blend_offset` fields), `blendDensity`, `blendBiome` and the carving filter. Vanilla adds weighted sums over a fastutil `Long2ObjectOpenHashMap` in its entry order, and a sum's last bits depend on it, so the maps walk their entries in that order (`OpenMap`). - The generator takes an `OldWorld` (the chunks an older version saved): the biome chunks, the density graph (`WorldField::BlendAlpha/BlendOffset` and the `blend_density` hook that already existed) and the carving mask use the chunk's `Blender`; an old chunk keeps the biomes it was saved with. - `old_world.rs` (horizon-client): which saved chunks are old (`IOWorker.isOldChunk`: DataVersion below 4997 or `blending_data`, scanned per region), their `blending_data`, the border columns from the decoded chunk and the biomes they keep. `BlendingData.isGround` and `SURFACE_BLOCKS` come from the block collision table (`GeneratorData::is_old_chunk_ground`). - `HORIZON_DISABLE_BLENDING` turns it off, as vanilla's `SharedConstants.DEBUG_DISABLE_BLENDING`. The starts an old chunk saved (`structures.starts`) come back with their pieces, as `StructureStart.loadStaticStart` loads them, so the neighbours place the parts that cross the border and the `Beardifier` sees them: a jigsaw start (villages, pillager outposts, bastions, ancient cities, trial chambers, trail ruins) is loaded from its saved `Children` (`PoolPiece::from_saved`). The pieces of the other structures (mineshafts, fortresses, strongholds, monuments, temples, shipwrecks, end cities, ruined portals) have no NBT loader yet: such a start is the generator's own when that has the same name and the same pieces' box (the same layout from the same seed), else it is the name and the box alone, which `/locate` and maps find but nothing places. Not in this PR: `Blender.generateBorderTicks` (leaves and fluids at the old/new border are not marked for post-processing yet), and the below-zero retrogen of chunks that are not full. ## Proof **Against vanilla, block for block.** `python3 tools/test_blending_parity.py`: `VanillaChunkGenerationOracle` (new `HORIZON_OLD_CHUNKS`) makes chunks of another seed count as saved by an older version and generates the target chunks around them with the real `Blender.of(region)`; the `chunk_dump` probe does the same. 185 chunks in four cases (a wall of old chunks, a single one, a block of four with another seed, far from the origin): 0 differing blocks, 0 differing biome cells. Without blending the same chunks differ by tens of thousands of blocks. **In the game.** `python3 tools/old_world_e2e.py`: 136 chunks of a seed-111 world are put into a seed-4242 world as old chunks (`old_world_fixture`), west of x = 0; the game generates the east. The same world is opened with blending (this PR) and with `HORIZON_DISABLE_BLENDING`. Real screenshots of the running game, same camera: | | Without blending | With blending | |---|---|---| | From above the new side, looking west | ![](https://raw.githubusercontent.com/xFedeT/horizon/pr-screenshots/blending/not-blended-from-the-new-side.png) | ![](https://raw.githubusercontent.com/xFedeT/horizon/pr-screenshots/blending/blended-from-the-new-side.png) | | Along the border | ![](https://raw.githubusercontent.com/xFedeT/horizon/pr-screenshots/blending/not-blended-along-the-border.png) | ![](https://raw.githubusercontent.com/xFedeT/horizon/pr-screenshots/blending/blended-along-the-border.png) | Without it, the new terrain stops at a stone wall of about 40 blocks where the old chunks begin. With it, the land runs on from the old chunks and settles to the new terrain's height. (The two games' windows had different sizes, so the screenshots differ in resolution; the camera positions are the same.) `pr_ready --quick`: fmt, clippy, 1257 tests and 480 python tests pass; parity harnesses left to CI. This is over 500 lines because the port is one piece (the module, its wiring, the saved-chunk reader and the proofs); the two commits are the generator side and the client side. 🤖 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-03 05:13:49 +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#5617
No description provided.