[PR #4211] [MERGED] /fillbiome recolours loaded chunks for every client (ClientboundChunksBiomesPacket) #5488

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4211
Author: @d3grando
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3518-chunks-biomes


📝 Commits (2)

  • 350d5db Send and handle ClientboundChunksBiomesPacket so /fillbiome recolours loaded chunks
  • 33743fb Merge main; port put_biomes to the column layout

📊 Changes

7 files changed (+360 additions, -43 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/terrain_cmds.rs (+10 -0)
📝 crates/horizon-client/src/game/remote.rs (+1 -0)
📝 crates/horizon-client/src/game/remote_chunks.rs (+127 -32)
📝 crates/horizon-client/src/lan/chunks.rs (+27 -11)
📝 crates/horizon-client/src/lan/hub.rs (+20 -0)
📝 crates/horizon-client/tests/lan_bot.rs (+69 -0)
📝 crates/horizon-protocol/src/packets/play.rs (+106 -0)

📄 Description

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

What and why

/fillbiome changed the server's biomes, but no client was ever told about it. ClientboundChunksBiomesPacket (id 13) existed only as a constant in ids.rs: there was no packet struct, the server never sent it, and the client had no handler (it decoded as Unknown and was dropped). So grass, leaves, water and foliage kept the old biome colour until the column was sent again. This hit every client: single player on its server thread (the default), LAN guests and dedicated-server players. The ledger row is ClientPacketListener.handleChunksBiomes.

The change follows vanilla on both sides:

  • Protocol: ChunksBiomes { chunks: Vec<ChunkBiomeData> } and ChunkBiomeData { pos, buffer }. On the wire this is a list of (ChunkPos packed in one long, byteArray(2097152)). The bytes hold each section's biome container, one after another. ChunkBiomeData::biomes reads the containers and from_biomes writes them.
  • Server: cmd_fillbiome now calls Hub::resend_biomes with the columns it changed, in FillBiomeCommand.fill's order (z, then x; columns with no change are left out). resend_biomes is ChunkMap.resendBiomesForChunks: every player in the level gets one packet holding the columns it has already been sent (getPlayers(pos, false)). ChunkEncoder::biome_data writes the level's sections' biome containers (ChunkBiomeData.extractChunkData), using the same per-section encoding as the chunk packet (SectionCoder::biomes, moved out of section).
  • Client: remote_chunks_biomes is handleChunksBiomes:
    • It skips a column outside the view range or not loaded, with vanilla's warnings (ClientChunkCache.replaceBiomes).
    • Otherwise it replaces the column's biomes section by section (LevelChunk.replaceBiomes).
    • It then marks every section of the column and its eight neighbours dirty, because biome colours blend across columns (setSectionDirty over dx/dz -1..1 and every section Y).
    • The biome mapping and the filling of sections outside the dimension's range (the Nether and the End) moved into ChunkFormat::put_biomes. Chunk packets and the new packet now share it.

Part of #3518 (the ClientPacketListener.handleChunksBiomes row).

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

Read with javap on the 26.3 jars:

  • net.minecraft.network.protocol.game.ClientboundChunksBiomesPacket (STREAM_CODEC, forChunks) and ClientboundChunksBiomesPacket$ChunkBiomeData (STREAM_CODEC = ChunkPos.STREAM_CODEC + ByteBufCodecs.byteArray(2097152), extractChunkData, getReadBuffer); ChunkPos$1 (FriendlyByteBuf.writeChunkPos)
  • net.minecraft.server.commands.FillBiomeCommand.fill (chunk list in z-then-x order, unchanged chunks removed, then ChunkMap.resendBiomesForChunks)
  • net.minecraft.server.level.ChunkMap.resendBiomesForChunks (per player getPlayers(pos, false), one packet each)
  • net.minecraft.client.multiplayer.ClientPacketListener.handleChunksBiomes, ClientChunkCache.replaceBiomes, LevelChunk.replaceBiomes

No parity harness covers this packet. These tests check it:

  • horizon-protocol chunks_biomes_is_a_known_packet and chunks_biomes_wire_and_biomes check vanilla's byte layout.
  • lan_bot changed_biomes_reach_the_players_that_see_the_column checks the host end to end over a real socket: only the column the player was sent is resent, and its cell decodes to the new biome.
  • remote_chunks chunks_biomes_replace_a_columns_biomes checks the client replacement in the Nether (section offset, the edges above and below, blocks kept, and an error on a short buffer).

Self-check

tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so these are the commands it would run for the touched crates, run by hand:

cargo fmt --all -- --check                                                  # ok
cargo clippy -p horizon-protocol -p horizon-client --all-targets -- -D warnings   # ok, no warnings
cargo test -p horizon-protocol --lib                                        # 112 passed
cargo test -p horizon-client --bin horizon-client -- remote_chunks::        # 2 passed
cargo test -p horizon-client --test lan_bot                                 # 9 passed (with the prepared resources)
cargo build --profile fast -p horizon-client --bins                         # ok

The new test fails before the fix and passes after. I ran chunks_biomes_is_a_known_packet, which only uses names that already exist on main, against unchanged origin/main (bd9b32587):

test packets::play::tests::chunks_biomes_is_a_known_packet ... FAILED
panicked at crates\horizon-protocol\src\packets\play.rs:3109:9:
Unknown(13, [1, 255, 255, 255, 254, 0, 0, 0, 1, 2, 5, 6])

With this branch it passes. The lan_bot and remote_chunks tests call the new Hub::resend_biomes and ChunkFormat::replace_biomes, so they don't compile without the fix.

In game, I built origin/main and this branch side by side. Single player ran on its server thread, and a second game joined as a LAN guest.

  • origin/main: after /fillbiome ~-20 ~-4 ~-20 ~20 ~4 ~20 minecraft:badlands the host's own view stayed green. The LAN guest also kept the old colour after the host's /fillbiome ... minecraft:jungle.
  • This branch: the host's grass turned badlands brown at once. Then the guest's grass turned jungle green at once, with no reload. Neither game logged a warning.

Screenshots

  • Single player (server thread), same spot, noon, after /fillbiome ... minecraft:badlands: on origin/main the grass and tall grass stay plains green. With this branch they turn badlands brown at once.
  • LAN guest, same spot, while the host runs /fillbiome ... minecraft:jungle over badlands: on origin/main the guest keeps the brown badlands colour. With this branch the guest's grass turns jungle green at once.

🤖 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/4211 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3518-chunks-biomes` --- ### 📝 Commits (2) - [`350d5db`](https://github.com/horizon-rust/horizon/commit/350d5dbe2d90790f3f4c2b23e5dff81595109301) Send and handle ClientboundChunksBiomesPacket so /fillbiome recolours loaded chunks - [`33743fb`](https://github.com/horizon-rust/horizon/commit/33743fb0527e58bb4a5595063416b18eed76c8a0) Merge main; port put_biomes to the column layout ### 📊 Changes **7 files changed** (+360 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/terrain_cmds.rs` (+10 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -0) 📝 `crates/horizon-client/src/game/remote_chunks.rs` (+127 -32) 📝 `crates/horizon-client/src/lan/chunks.rs` (+27 -11) 📝 `crates/horizon-client/src/lan/hub.rs` (+20 -0) 📝 `crates/horizon-client/tests/lan_bot.rs` (+69 -0) 📝 `crates/horizon-protocol/src/packets/play.rs` (+106 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why `/fillbiome` changed the server's biomes, but no client was ever told about it. `ClientboundChunksBiomesPacket` (id 13) existed only as a constant in `ids.rs`: there was no packet struct, the server never sent it, and the client had no handler (it decoded as `Unknown` and was dropped). So grass, leaves, water and foliage kept the old biome colour until the column was sent again. This hit every client: single player on its server thread (the default), LAN guests and dedicated-server players. The ledger row is `ClientPacketListener.handleChunksBiomes`. The change follows vanilla on both sides: - **Protocol:** `ChunksBiomes { chunks: Vec<ChunkBiomeData> }` and `ChunkBiomeData { pos, buffer }`. On the wire this is a list of (ChunkPos packed in one long, `byteArray(2097152)`). The bytes hold each section's biome container, one after another. `ChunkBiomeData::biomes` reads the containers and `from_biomes` writes them. - **Server:** `cmd_fillbiome` now calls `Hub::resend_biomes` with the columns it changed, in `FillBiomeCommand.fill`'s order (z, then x; columns with no change are left out). `resend_biomes` is `ChunkMap.resendBiomesForChunks`: every player in the level gets one packet holding the columns it has already been sent (`getPlayers(pos, false)`). `ChunkEncoder::biome_data` writes the level's sections' biome containers (`ChunkBiomeData.extractChunkData`), using the same per-section encoding as the chunk packet (`SectionCoder::biomes`, moved out of `section`). - **Client:** `remote_chunks_biomes` is `handleChunksBiomes`: - It skips a column outside the view range or not loaded, with vanilla's warnings (`ClientChunkCache.replaceBiomes`). - Otherwise it replaces the column's biomes section by section (`LevelChunk.replaceBiomes`). - It then marks every section of the column and its eight neighbours dirty, because biome colours blend across columns (`setSectionDirty` over dx/dz -1..1 and every section Y). - The biome mapping and the filling of sections outside the dimension's range (the Nether and the End) moved into `ChunkFormat::put_biomes`. Chunk packets and the new packet now share it. Part of #3518 (the `ClientPacketListener.handleChunksBiomes` row). ## 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 Read with javap on the 26.3 jars: - `net.minecraft.network.protocol.game.ClientboundChunksBiomesPacket` (`STREAM_CODEC`, `forChunks`) and `ClientboundChunksBiomesPacket$ChunkBiomeData` (`STREAM_CODEC` = `ChunkPos.STREAM_CODEC` + `ByteBufCodecs.byteArray(2097152)`, `extractChunkData`, `getReadBuffer`); `ChunkPos$1` (`FriendlyByteBuf.writeChunkPos`) - `net.minecraft.server.commands.FillBiomeCommand.fill` (chunk list in z-then-x order, unchanged chunks removed, then `ChunkMap.resendBiomesForChunks`) - `net.minecraft.server.level.ChunkMap.resendBiomesForChunks` (per player `getPlayers(pos, false)`, one packet each) - `net.minecraft.client.multiplayer.ClientPacketListener.handleChunksBiomes`, `ClientChunkCache.replaceBiomes`, `LevelChunk.replaceBiomes` No parity harness covers this packet. These tests check it: - `horizon-protocol` `chunks_biomes_is_a_known_packet` and `chunks_biomes_wire_and_biomes` check vanilla's byte layout. - `lan_bot` `changed_biomes_reach_the_players_that_see_the_column` checks the host end to end over a real socket: only the column the player was sent is resent, and its cell decodes to the new biome. - `remote_chunks` `chunks_biomes_replace_a_columns_biomes` checks the client replacement in the Nether (section offset, the edges above and below, blocks kept, and an error on a short buffer). ## Self-check `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so these are the commands it would run for the touched crates, run by hand: ``` cargo fmt --all -- --check # ok cargo clippy -p horizon-protocol -p horizon-client --all-targets -- -D warnings # ok, no warnings cargo test -p horizon-protocol --lib # 112 passed cargo test -p horizon-client --bin horizon-client -- remote_chunks:: # 2 passed cargo test -p horizon-client --test lan_bot # 9 passed (with the prepared resources) cargo build --profile fast -p horizon-client --bins # ok ``` The new test fails before the fix and passes after. I ran `chunks_biomes_is_a_known_packet`, which only uses names that already exist on main, against unchanged `origin/main` (bd9b32587): ``` test packets::play::tests::chunks_biomes_is_a_known_packet ... FAILED panicked at crates\horizon-protocol\src\packets\play.rs:3109:9: Unknown(13, [1, 255, 255, 255, 254, 0, 0, 0, 1, 2, 5, 6]) ``` With this branch it passes. The `lan_bot` and `remote_chunks` tests call the new `Hub::resend_biomes` and `ChunkFormat::replace_biomes`, so they don't compile without the fix. In game, I built origin/main and this branch side by side. Single player ran on its server thread, and a second game joined as a LAN guest. - **origin/main:** after `/fillbiome ~-20 ~-4 ~-20 ~20 ~4 ~20 minecraft:badlands` the host's own view stayed green. The LAN guest also kept the old colour after the host's `/fillbiome ... minecraft:jungle`. - **This branch:** the host's grass turned badlands brown at once. Then the guest's grass turned jungle green at once, with no reload. Neither game logged a warning. ## Screenshots - **Single player (server thread), same spot, noon, after `/fillbiome ... minecraft:badlands`:** on origin/main the grass and tall grass stay plains green. With this branch they turn badlands brown at once. - **LAN guest, same spot, while the host runs `/fillbiome ... minecraft:jungle` over badlands:** on origin/main the guest keeps the brown badlands colour. With this branch the guest's grass turns jungle green at once. 🤖 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:12:56 +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#5488
No description provided.