[PR #5733] [MERGED] perf(world): bulk block edits into chunk sections; resent columns relit only where they changed #6465

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5733
Author: @Stink-O
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/bulk-block-edits


📝 Commits (10+)

  • 1bfb260 perf(world): bulk block edits into chunk sections; resent columns relit only where they changed
  • 1606f86 Clippy: the changed cells' rows through as_chunks, not chunks_exact (Rust 1.99's lint)
  • 37d4b92 Merge main into #5733
  • 53b34ed fix(world): bulk edits follow each chunk's layout; resent columns keep new biomes
  • f27e5c5 Merge remote-tracking branch 'hr/main' into pr-5733
  • a34c63b Bulk edits: a resent column keeps the packet's light where it changed; the anticheat and the far ring hear of bulk chunks
  • 1d34a59 Merge remote-tracking branch 'hr/main' into pr-5733
  • d4da246 Merge main into #5733
  • c507ec4 Resent columns: a section with the same blocks takes the packet's new light
  • 74404c2 Merge main into #5733

📊 Changes

10 files changed (+656 additions, -19 deletions)

View changed files

➕ crates/horizon-client-render/src/block_edit.rs (+306 -0)
📝 crates/horizon-client-render/src/chunk.rs (+9 -0)
📝 crates/horizon-client-render/src/lib.rs (+1 -0)
📝 crates/horizon-client-render/src/light.rs (+60 -13)
📝 crates/horizon-client-render/src/streaming.rs (+174 -1)
📝 crates/horizon-client-render/src/world.rs (+4 -0)
📝 crates/horizon-client/src/game/remote_chunks.rs (+8 -1)
📝 crates/horizon-client/src/lan/hub.rs (+63 -0)
📝 crates/horizon-client/src/lib.rs (+4 -4)
📝 crates/horizon-core/src/paletted.rs (+27 -0)

📄 Description

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

What and why

Fixes #5732. This is the first of three stacked PRs for bulk world access by server mods: #5733 → #5735 → #5737.
It's part of #5727, the hooks Orbital Laser needs as a native mod, whose
craters change hundreds of thousands of blocks. This one is the engine side and adds no API.

  1. World::edit_runs (crates/horizon-client-render/src/block_edit.rs) writes runs of blocks up columns
    straight into chunk sections, within each chunk's own layout (min_y(), max_y(), sections.len(), so taller
    data-pack dimensions work).
    • Each section is unpacked and repacked once (Chunk::replace_blocks). The state filter, and whether a state is
      tracked, are asked once per state.
    • Nothing round the blocks is updated, as with fill … strict. Block entities and watched blocks are reported back
      (Outcome::tracked) for the caller, which is #5735.
    • The chunks changed are relit whole off the game thread, and each changed section is remeshed once.
    • Its doc lists what the per-block path records and this one doesn't, so a caller knows:
      block_entities.state_changed, watched_writes (ask through tracked), block_log (these go to bulk_log),
      path_writes, and light_edits (relit whole through dirty_light).
  2. Whole chunks to players (lan/hub.rs): a chunk changed in bulk goes to each player who has it as one
    ClientboundLevelChunkWithLightPacket instead of thousands of block updates. The per-block updates queued for it
    that tick are dropped, since the chunk carries them.
  3. Cheaper resent columns on the client (Streaming::replace_remote, keep_unchanged_sections).
    • When a server sends a column again while it's still resident, the client keeps the old sections whose blocks are
      stored alike (PalettedContainer::same_storage), and keeps their light.
    • Biomes always come from the new packet. A section whose biomes changed is remeshed with its neighbours.
    • The column is relit locally, and remeshes only round the cells that changed
      (LightChanges::classes_differing), as vanilla's setBlocksDirty does.

This changes behaviour on every server, not only Horizon's. A real server (vanilla, Paper) resending a resident
column used to have it replaced and relit whole. Now its unchanged sections, and their light, are kept and relit
locally. What the player sees is the same: the blocks, biomes and light that come out match a fresh load, which the
tests check. The LAN light check below covers the path through a server's resend.

Nothing calls edit_runs until #5735. Parts 2 and 3 work on their own.

Kind

  • perf

Vanilla reference

  • ClientboundLevelChunkWithLightPacket for the chunks changed in bulk.
  • LevelRenderer.setBlocksDirty for what remeshes.
  • FillCommand with strict for what the edit leaves alone.

Other projects' code

None from other projects. Ported from the author's own fork of Horizon (Stink-O/horizon, MIT):
ee55a05e6,
8820a77ca.

How it was tested

  • cargo test -p horizon-client-render --lib block_edit → test result: ok. 5 passed (runs in order, unloaded
    chunks and unchanged blocks left out, tracked states reported, heightmaps follow the edit, and new:
    runs_follow_each_chunks_own_layout on a -128..=511 layout).
  • cargo test -p horizon-client-render --lib streaming → test result: ok. 20 passed; 2 ignored (new:
    a_resent_column_keeps_its_sections_but_takes_new_biomes).
  • cargo test -p horizon-client-render --lib light → test result: ok. 45 passed; 6 ignored.
  • cargo test -p horizon-core --lib paletted → test result: ok. 11 passed; 2 ignored.
  • python3 tools/lan_e2e.py --check light --check walls --check chest (fast build of 53b34ed9b; this is a
    needs-proof PR: lan/hub.rs, remote_chunks.rs):
    • light: PASS (torch 4205, roof 1183, hole 1183, border 1904, border_cleared 1904);
    • walls: PASS.
    • chest: FAILED once (the guest game exited after setblock … chest, with no panic in its log) and passed when run
      again on its own.
    • Repeated on main (5edb339a7) and on #5737's head (b808a05dd, which holds this), alternating, three runs of
      --check chest --check light each, prebuilt fast binaries: chest passed 6 of 6. light failed 2 of 3 on main
      and 1 of 3 on the branch, always with "border chunk: no position of the box is loaded on both sides" (the
      check's own wait for chunks to load on both sides). That flake is on main too, not from this stack; every run
      that got past it passed with the same numbers.

For the merge

  • Merge order: this first, then #5735, then #5737. Each contains the one before it (by merges, never rebases).
    Until this merges, their diffs show its commits too.
  • Conflicts: lan/hub.rs and streaming.rs move fast on main; main was merged in on 2026-11-01 (5edb339a7).
    #5739 also edits lan/hub.rs (other functions): keep both sides. After this merges, merge main into #5735 and its
    diff shrinks to its own change.
  • Risk: medium: the network path to players and the client's handling of resent chunks. Rollback:
    git revert -m 1 <merge commit>, after reverting #5737 and #5735 if they merged. No API number is involved here.

Self-check

pr_ready (RUSTUP_TOOLCHAIN=1.99 tools/pr_ready.py --quick --base origin/main, 5 min 26 s, 2026-11-01)

Check Result
Scope ⚠️ 10 files, +606 −26 (632 lines of code: over 500; the engine #5735 builds on)
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed
rustfmt ✅
clippy ✅ (Rust 1.99, as CI)
tests: horizon-client, horizon-client-render, horizon-core ✅ 2622 passed
doc tests ✅ 0 passed
Parity ➖ not run (--quick)

CI's two clippy commands, Rust 1.99: cargo clippy --workspace --all-targets -- -D warnings and cargo clippy -p horizon-client --all-targets --no-default-features -- -D warnings: both pass.

🤖 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/5733 **Author:** [@Stink-O](https://github.com/Stink-O) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/bulk-block-edits` --- ### 📝 Commits (10+) - [`1bfb260`](https://github.com/horizon-rust/horizon/commit/1bfb26017b2d1be1cbae0ef03d89b098a9d07991) perf(world): bulk block edits into chunk sections; resent columns relit only where they changed - [`1606f86`](https://github.com/horizon-rust/horizon/commit/1606f86e4ccda46049c9af9e1d5d219a2210a9a6) Clippy: the changed cells' rows through as_chunks, not chunks_exact (Rust 1.99's lint) - [`37d4b92`](https://github.com/horizon-rust/horizon/commit/37d4b92459cae8d49038d77fae442c7acb421aca) Merge main into #5733 - [`53b34ed`](https://github.com/horizon-rust/horizon/commit/53b34ed9b63b4ae88b12feb636777c72a78b3e48) fix(world): bulk edits follow each chunk's layout; resent columns keep new biomes - [`f27e5c5`](https://github.com/horizon-rust/horizon/commit/f27e5c57961653f1018b6ec9db906b482aff4d14) Merge remote-tracking branch 'hr/main' into pr-5733 - [`a34c63b`](https://github.com/horizon-rust/horizon/commit/a34c63b88c2438d6cc2c7af2f4d16cb569dc9fa9) Bulk edits: a resent column keeps the packet's light where it changed; the anticheat and the far ring hear of bulk chunks - [`1d34a59`](https://github.com/horizon-rust/horizon/commit/1d34a593723984b69b203267d55bd4a6463a9915) Merge remote-tracking branch 'hr/main' into pr-5733 - [`d4da246`](https://github.com/horizon-rust/horizon/commit/d4da2469cc952bcb16eafe30ff9e1afb2ece0adb) Merge main into #5733 - [`c507ec4`](https://github.com/horizon-rust/horizon/commit/c507ec473026c6aa3dc1c8cfc93eb01e076b56c8) Resent columns: a section with the same blocks takes the packet's new light - [`74404c2`](https://github.com/horizon-rust/horizon/commit/74404c28fcf22f93908b07029bb701cd23949f10) Merge main into #5733 ### 📊 Changes **10 files changed** (+656 additions, -19 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client-render/src/block_edit.rs` (+306 -0) 📝 `crates/horizon-client-render/src/chunk.rs` (+9 -0) 📝 `crates/horizon-client-render/src/lib.rs` (+1 -0) 📝 `crates/horizon-client-render/src/light.rs` (+60 -13) 📝 `crates/horizon-client-render/src/streaming.rs` (+174 -1) 📝 `crates/horizon-client-render/src/world.rs` (+4 -0) 📝 `crates/horizon-client/src/game/remote_chunks.rs` (+8 -1) 📝 `crates/horizon-client/src/lan/hub.rs` (+63 -0) 📝 `crates/horizon-client/src/lib.rs` (+4 -4) 📝 `crates/horizon-core/src/paletted.rs` (+27 -0) </details> ### 📄 Description > 🤖 Opened by Stink-O's AI agent (Claude Code, Claude Opus 5.5), not by Stink-O personally. ## What and why Fixes #5732. This is the first of three stacked PRs for bulk world access by server mods: #5733 → #5735 → #5737. It's part of #5727, the hooks [Orbital Laser](https://github.com/Stink-O/orbital-laser) needs as a native mod, whose craters change hundreds of thousands of blocks. This one is the engine side and adds no API. 1. **`World::edit_runs`** (`crates/horizon-client-render/src/block_edit.rs`) writes runs of blocks up columns straight into chunk sections, within each chunk's own layout (`min_y()`, `max_y()`, `sections.len()`, so taller data-pack dimensions work). - Each section is unpacked and repacked once (`Chunk::replace_blocks`). The state filter, and whether a state is tracked, are asked once per state. - Nothing round the blocks is updated, as with `fill … strict`. Block entities and watched blocks are reported back (`Outcome::tracked`) for the caller, which is #5735. - The chunks changed are relit whole off the game thread, and each changed section is remeshed once. - Its doc lists what the per-block path records and this one doesn't, so a caller knows: `block_entities.state_changed`, `watched_writes` (ask through `tracked`), `block_log` (these go to `bulk_log`), `path_writes`, and `light_edits` (relit whole through `dirty_light`). 2. **Whole chunks to players** (`lan/hub.rs`): a chunk changed in bulk goes to each player who has it as one `ClientboundLevelChunkWithLightPacket` instead of thousands of block updates. The per-block updates queued for it that tick are dropped, since the chunk carries them. 3. **Cheaper resent columns on the client** (`Streaming::replace_remote`, `keep_unchanged_sections`). - When a server sends a column again while it's still resident, the client keeps the old sections whose blocks are stored alike (`PalettedContainer::same_storage`), and keeps their light. - Biomes always come from the new packet. A section whose biomes changed is remeshed with its neighbours. - The column is relit locally, and remeshes only round the cells that changed (`LightChanges::classes_differing`), as vanilla's `setBlocksDirty` does. **This changes behaviour on every server, not only Horizon's.** A real server (vanilla, Paper) resending a resident column used to have it replaced and relit whole. Now its unchanged sections, and their light, are kept and relit locally. What the player sees is the same: the blocks, biomes and light that come out match a fresh load, which the tests check. The LAN light check below covers the path through a server's resend. Nothing calls `edit_runs` until #5735. Parts 2 and 3 work on their own. ## Kind - [x] perf ## Vanilla reference - `ClientboundLevelChunkWithLightPacket` for the chunks changed in bulk. - `LevelRenderer.setBlocksDirty` for what remeshes. - `FillCommand` with `strict` for what the edit leaves alone. ## Other projects' code None from other projects. Ported from the author's own fork of Horizon (Stink-O/horizon, MIT): [ee55a05e6](https://github.com/Stink-O/horizon/commit/ee55a05e6), [8820a77ca](https://github.com/Stink-O/horizon/commit/8820a77ca). ## How it was tested - `cargo test -p horizon-client-render --lib block_edit` → `test result: ok. 5 passed` (runs in order, unloaded chunks and unchanged blocks left out, tracked states reported, heightmaps follow the edit, and new: `runs_follow_each_chunks_own_layout` on a -128..=511 layout). - `cargo test -p horizon-client-render --lib streaming` → `test result: ok. 20 passed; 2 ignored` (new: `a_resent_column_keeps_its_sections_but_takes_new_biomes`). - `cargo test -p horizon-client-render --lib light` → `test result: ok. 45 passed; 6 ignored`. - `cargo test -p horizon-core --lib paletted` → `test result: ok. 11 passed; 2 ignored`. - `python3 tools/lan_e2e.py --check light --check walls --check chest` (fast build of 53b34ed9b; this is a `needs-proof` PR: `lan/hub.rs`, `remote_chunks.rs`): - light: PASS (torch 4205, roof 1183, hole 1183, border 1904, border_cleared 1904); - walls: PASS. - chest: FAILED once (the guest game exited after `setblock … chest`, with no panic in its log) and passed when run again on its own. - Repeated on main (5edb339a7) and on #5737's head (b808a05dd, which holds this), alternating, three runs of `--check chest --check light` each, prebuilt fast binaries: chest passed 6 of 6. light failed 2 of 3 on main and 1 of 3 on the branch, always with "border chunk: no position of the box is loaded on both sides" (the check's own wait for chunks to load on both sides). That flake is on main too, not from this stack; every run that got past it passed with the same numbers. ## For the merge - **Merge order:** this first, then #5735, then #5737. Each contains the one before it (by merges, never rebases). Until this merges, their diffs show its commits too. - **Conflicts:** `lan/hub.rs` and `streaming.rs` move fast on main; main was merged in on 2026-11-01 (5edb339a7). #5739 also edits `lan/hub.rs` (other functions): keep both sides. After this merges, merge main into #5735 and its diff shrinks to its own change. - **Risk:** medium: the network path to players and the client's handling of resent chunks. **Rollback:** `git revert -m 1 <merge commit>`, after reverting #5737 and #5735 if they merged. No API number is involved here. ## Self-check **pr_ready** (`RUSTUP_TOOLCHAIN=1.99 tools/pr_ready.py --quick --base origin/main`, 5 min 26 s, 2026-11-01) | Check | Result | | --- | --- | | Scope | ⚠️ 10 files, +606 −26 (632 lines of code: over 500; the engine #5735 builds on) | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed | | rustfmt | ✅ | | clippy | ✅ (Rust 1.99, as CI) | | tests: horizon-client, horizon-client-render, horizon-core | ✅ 2622 passed | | doc tests | ✅ 0 passed | | Parity | ➖ not run (--quick) | CI's two clippy commands, Rust 1.99: `cargo clippy --workspace --all-targets -- -D warnings` and `cargo clippy -p horizon-client --all-targets --no-default-features -- -D warnings`: both pass. 🤖 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 06:21:05 +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#6465
No description provided.