[PR #5735] [MERGED] feat(mods): native server mods can edit blocks in bulk #6466

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

📋 Pull Request Information

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

Base: main ← Head: native/edit-blocks


📝 Commits (10+)

  • 1bfb260 perf(world): bulk block edits into chunk sections; resent columns relit only where they changed
  • 33fd914 feat(mods): native server mods can edit blocks in bulk
  • 1606f86 Clippy: the changed cells' rows through as_chunks, not chunks_exact (Rust 1.99's lint)
  • ace8c98 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
  • 78d6f69 Merge branch 'native/bulk-block-edits' into native/edit-blocks
  • 41ae4e9 fix(mods): bulk edits check every run first and make block entities as native_set_block does
  • c43496c fix(mods): one entry lookup a block entity name (clippy map_entry)
  • f27e5c5 Merge remote-tracking branch 'hr/main' into pr-5733

📊 Changes

16 files changed (+1232 additions, -39 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.rs (+2 -0)
➕ crates/horizon-client/src/game/block_edits.rs (+443 -0)
📝 crates/horizon-client/src/game/commands.rs (+35 -20)
➕ crates/horizon-client/src/game/native_world_edit.rs (+68 -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)
📝 docs/native-mods.md (+20 -0)
➕ tools/native-hook-fragments/native_edit_blocks.json (+8 -0)

📄 Description

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

Stacked on #5733: merge that first. Until it merges, this diff also shows its commits. This PR's own change is
game/block_edits.rs, game/native_world_edit.rs, block_input_matches in game/commands.rs, the docs section and
the fragment: +514 −20 against #5733.

What and why

Fixes #5734. Part of #5727, the hooks Orbital Laser needs as a native mod
(its craters change up to a few hundred thousand blocks a strike). It's useful to any server mod that changes many
blocks: world generators, terraformers, schematic pasters. Today a server mod has native_set_block: one block per
call, each with neighbour updates and its own packet.

Game::native_edit_blocks(dimension, &NativeBlockEdit) -> Result<u64, String>, for server mods, in the level being
ticked (as native_set_block):

  • palette: block states as commands write them (minecraft:oak_log[axis=x]). filters: block predicates
    (#minecraft:logs, minecraft:stone). Entries with NBT are refused.
  • runs: height blocks up column (x, z) from y, or from a heightmap's height plus y (heights are read before
    any change), set to palette entry block, only where filter only passes.
  • Every run's indices are checked before anything changes (resolve_runs). An index past the palette or the
    filters, or more than 65,536 filters, is an Err with nothing changed.
  • The blocks are made at once through #5733's World::edit_runs, with what fill … strict does:
    • no neighbour or shape updates;
    • the old block entity is removed and the new block's is made, as native_set_block makes it (a mod block's
      ModBlockEntity too, through new_block_entity);
    • the chunks changed go to their players whole.

It returns the number of blocks changed, or why nothing changed: another dimension, a client of a server, a palette
entry or filter that doesn't parse or has NBT, or an index out of range.

  • Game::block_matches (the commands' predicate) now calls the new free block_input_matches, so both share one
    matcher.
  • docs/native-mods.md gets a "Bulk block edits" section.
  • It's a helper only: fragment tools/native-hook-fragments/native_edit_blocks.json. No API number is edited.

Kind

  • feature

Vanilla reference

Horizon-only. The palette and filters are read as BlockStateArgument / BlockPredicateArgument, block entities as
FillCommand with strict, and heights as Heightmap.Types.

Other projects' code

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

How it was tested

  • cargo test -p horizon-client --bin horizon-client block_edits → test result: ok. 4 passed. The new tests:
    • palette and filter indices past the end (up to u32::MAX) give Err with nothing resolved;
    • the filter-count bound;
    • a run counted from a heightmap, read once a column;
    • a chest replaced by stone loses its block entity, and a mod block gets the ModBlockEntity made for it.
  • cargo test -p horizon-client --bin horizon-client commands passes (the commands' predicate now goes through
    block_input_matches).
  • Stamped locally in a scratch worktree, not committed, on #5737's head (which includes this):
    python3 tools/stamp_native_hooks.py → Stamped 6 fragment(s), through API 86.
  • Orbital Laser's native build (all its craters go through this) matched the fork's strikes for all 11 lasers in the
    catch-up's parity runs, game_check clean (before this round's review fixes; the fixes add
    checks and tests, the edit itself is unchanged).

For the merge

  • Merge order: after #5733; #5737 follows this.
  • Conflicts: after #5733 merges, git merge origin/main here drops the shared commits. Fragment files: keep all.
    #5686 edits cmd_fill in the same commands.rs; both apply cleanly.
  • Risk: the helper is new, and nothing calls it unless a mod does. The block_matches refactor keeps its two tag
    lookups exactly as before. Rollback: revert before the stamp PR merges; after that, fix forward. Revert #5737
    first if it merged.

Self-check

pr_ready (RUSTUP_TOOLCHAIN=1.99 tools/pr_ready.py --quick --base native/bulk-block-edits, 2 min 39 s, 2026-11-01)

Check Result
Scope ⚠️ 6 files, +514 −20 (514 lines of code: over 500)
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed
rustfmt ✅
clippy ✅ (Rust 1.99, as CI)
tests: horizon-client ✅ 1663 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/5735 **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/edit-blocks` --- ### 📝 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 - [`33fd914`](https://github.com/horizon-rust/horizon/commit/33fd9148b0b355db51199ca6fb6c9a7d5ffd4245) feat(mods): native server mods can edit blocks in bulk - [`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) - [`ace8c98`](https://github.com/horizon-rust/horizon/commit/ace8c981f5fe46fd2068354e91042d0bef00de6e) 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 - [`78d6f69`](https://github.com/horizon-rust/horizon/commit/78d6f69e90c01afcc0fedc58b8d0c224685d9011) Merge branch 'native/bulk-block-edits' into native/edit-blocks - [`41ae4e9`](https://github.com/horizon-rust/horizon/commit/41ae4e9ceba569b3aacef923af8ab85e1338a52b) fix(mods): bulk edits check every run first and make block entities as native_set_block does - [`c43496c`](https://github.com/horizon-rust/horizon/commit/c43496c5e851b9a89c28aa3a60738f017183e00e) fix(mods): one entry lookup a block entity name (clippy map_entry) - [`f27e5c5`](https://github.com/horizon-rust/horizon/commit/f27e5c57961653f1018b6ec9db906b482aff4d14) Merge remote-tracking branch 'hr/main' into pr-5733 ### 📊 Changes **16 files changed** (+1232 additions, -39 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.rs` (+2 -0) ➕ `crates/horizon-client/src/game/block_edits.rs` (+443 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+35 -20) ➕ `crates/horizon-client/src/game/native_world_edit.rs` (+68 -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) 📝 `docs/native-mods.md` (+20 -0) ➕ `tools/native-hook-fragments/native_edit_blocks.json` (+8 -0) </details> ### 📄 Description > 🤖 Opened by Stink-O's AI agent (Claude Code, Claude Opus 5.5), not by Stink-O personally. **Stacked on #5733: merge that first.** Until it merges, this diff also shows its commits. This PR's own change is `game/block_edits.rs`, `game/native_world_edit.rs`, `block_input_matches` in `game/commands.rs`, the docs section and the fragment: +514 −20 against #5733. ## What and why Fixes #5734. Part of #5727, the hooks [Orbital Laser](https://github.com/Stink-O/orbital-laser) needs as a native mod (its craters change up to a few hundred thousand blocks a strike). It's useful to any server mod that changes many blocks: world generators, terraformers, schematic pasters. Today a server mod has `native_set_block`: one block per call, each with neighbour updates and its own packet. `Game::native_edit_blocks(dimension, &NativeBlockEdit) -> Result<u64, String>`, for server mods, in the level being ticked (as `native_set_block`): - `palette`: block states as commands write them (`minecraft:oak_log[axis=x]`). `filters`: block predicates (`#minecraft:logs`, `minecraft:stone`). Entries with NBT are refused. - `runs`: `height` blocks up column (x, z) from `y`, or from a heightmap's height plus `y` (heights are read before any change), set to palette entry `block`, only where filter `only` passes. - Every run's indices are checked before anything changes (`resolve_runs`). An index past the palette or the filters, or more than 65,536 filters, is an `Err` with nothing changed. - The blocks are made at once through #5733's `World::edit_runs`, with what `fill … strict` does: - no neighbour or shape updates; - the old block entity is removed and the new block's is made, as `native_set_block` makes it (a mod block's `ModBlockEntity` too, through `new_block_entity`); - the chunks changed go to their players whole. It returns the number of blocks changed, or why nothing changed: another dimension, a client of a server, a palette entry or filter that doesn't parse or has NBT, or an index out of range. - `Game::block_matches` (the commands' predicate) now calls the new free `block_input_matches`, so both share one matcher. - docs/native-mods.md gets a "Bulk block edits" section. - It's a helper only: fragment `tools/native-hook-fragments/native_edit_blocks.json`. No API number is edited. ## Kind - [x] feature ## Vanilla reference Horizon-only. The palette and filters are read as `BlockStateArgument` / `BlockPredicateArgument`, block entities as `FillCommand` with `strict`, and heights as `Heightmap.Types`. ## 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). ## How it was tested - `cargo test -p horizon-client --bin horizon-client block_edits` → `test result: ok. 4 passed`. The new tests: - palette and filter indices past the end (up to `u32::MAX`) give `Err` with nothing resolved; - the filter-count bound; - a run counted from a heightmap, read once a column; - a chest replaced by stone loses its block entity, and a mod block gets the `ModBlockEntity` made for it. - `cargo test -p horizon-client --bin horizon-client commands` passes (the commands' predicate now goes through `block_input_matches`). - Stamped locally in a scratch worktree, not committed, on #5737's head (which includes this): `python3 tools/stamp_native_hooks.py` → `Stamped 6 fragment(s), through API 86`. - Orbital Laser's native build (all its craters go through this) matched the fork's strikes for all 11 lasers in the catch-up's parity runs, `game_check` clean (before this round's review fixes; the fixes add checks and tests, the edit itself is unchanged). ## For the merge - **Merge order:** after #5733; #5737 follows this. - **Conflicts:** after #5733 merges, `git merge origin/main` here drops the shared commits. Fragment files: keep all. #5686 edits `cmd_fill` in the same `commands.rs`; both apply cleanly. - **Risk:** the helper is new, and nothing calls it unless a mod does. The `block_matches` refactor keeps its two tag lookups exactly as before. **Rollback:** revert before the stamp PR merges; after that, fix forward. Revert #5737 first if it merged. ## Self-check **pr_ready** (`RUSTUP_TOOLCHAIN=1.99 tools/pr_ready.py --quick --base native/bulk-block-edits`, 2 min 39 s, 2026-11-01) | Check | Result | | --- | --- | | Scope | ⚠️ 6 files, +514 −20 (514 lines of code: over 500) | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed | | rustfmt | ✅ | | clippy | ✅ (Rust 1.99, as CI) | | tests: horizon-client | ✅ 1663 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:06 +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#6466
No description provided.