[PR #5737] [MERGED] feat(mods): native server mods can read surface heights and columns #6467

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

📋 Pull Request Information

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

Base: main ← Head: native/read-columns


📝 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
  • baabab5 feat(mods): native server mods can read surface heights and columns
  • 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)
  • 3d685f4 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

📊 Changes

18 files changed (+1604 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 (+3 -0)
➕ crates/horizon-client/src/game/block_edits.rs (+716 -0)
📝 crates/horizon-client/src/game/commands.rs (+35 -20)
➕ crates/horizon-client/src/game/native_world_columns.rs (+71 -0)
➕ 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 (+39 -0)
➕ tools/native-hook-fragments/native_edit_blocks.json (+8 -0)
➕ tools/native-hook-fragments/native_read_columns.json (+8 -0)

📄 Description

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

Stacked on #5735 (and so #5733): merge those first. This PR's own change is game/native_world_columns.rs, the
reads in game/block_edits.rs, the docs section and the fragment: +370 −24 against #5735.

What and why

Fixes #5736. Part of #5727, the hooks Orbital Laser needs as a native mod
(it reads the land under a strike to shape and colour its crater). It's useful to any server mod that surveys
terrain, such as server-side minimaps, terraformers and structure placers. Today a mod reads one block per call,
with no heights or tints.

For server mods, in the level being ticked:

  • native_surface_heights(dimension, columns, heightmap) -> Result<Vec<Option<i32>>, String>: each column's height
    on a heightmap (Heightmap.Types), None where its chunk isn't loaded; at most 65,536 columns a call.
  • native_read_columns(dimension, columns, heightmap, (below, above)) -> Result<NativeColumnBlocks, String>: those heights,
    and each column's blocks from below under to above over it, bottom first.
    • The blocks come as a palette of names and u16 indexes, with the biome's grass, foliage and water tints at the
      column's top. Thousands of columns fit in a call.
    • Blocks outside each chunk's own height, and every block of a column not loaded, read as air.
    • The tints are the biome's own at the column's top, not blended over the biome blend radius as the game draws
      them, so near a border they can differ from what players see by a few blocks.
    • It's bounded, with checked arithmetic: below + above must be 1 to the level's height, and a read at most
      1,048,576 blocks (MAX_READ; it runs on the server tick, so a big area is read in pieces).

Both return Err with the reason, reading nothing, as native_edit_blocks does: another dimension or a client of a
server, a span or read out of bounds, so a mod can tell "ask for less" from "wrong level". docs/native-mods.md gets a "Column reads"
section. They're helpers only: fragment tools/native-hook-fragments/native_read_columns.json.

Kind

  • feature

Vanilla reference

Horizon-only. Heights are Heightmap.Types; tints are BiomeColors.getAverageGrassColor / foliage / water.

Other projects' code

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

How it was tested

  • cargo test -p horizon-client --bin horizon-client block_edits → test result: ok. 8 passed (#5735's 4, and 4 new
    ones):
    • each heightmap's height (world surface, motion blocking, no leaves, ocean floor), with an empty column giving the
      bottom;
    • an unloaded column gives None;
    • blocks past the top, and in unloaded columns, read as air;
    • the size bound.
  • Stamped locally in a scratch worktree, not committed: python3 tools/stamp_native_hooks.py → Stamped 6 fragment(s), through API 86.
  • Orbital Laser's native build reads 3,000 columns × 24 blocks a call for the Sinkhole, the Payload, the Nuke and the
    Rod; its catch-up parity against the fork was clean (before this round's review fixes, which add the bounds).
  • python3 tools/lan_e2e.py --check light --check walls --check chest on this head (fast build): walls and chest
    PASS. light FAILED once ("border chunk: no position of the box is loaded on both sides", a check that the box's
    chunks load on both sides in time) 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: last of #5733 → #5735 → #5737.
  • Conflicts: after #5735 merges, git merge origin/main. Fragment files: keep all.
  • Risk: read-only helpers that nothing calls unless a mod does. Rollback: revert before the stamp PR merges;
    after that, fix forward.

Self-check

pr_ready (Rust 1.99.1, tools/pr_ready.py --quick --base native/edit-blocks on DESKTOP-SNGRNA4-LINUX, against native/edit-blocks at c43496c5e, 13 min 48 s)

Check Result
Scope ✅ 5 files, +396 −24
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 511 passed (21 s)
rustfmt ✅ (6 s)
clippy ✅ (40 s)
tests: horizon-client ✅ 1667 passed (12 min 39 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

CI's two clippy commands on Rust 1.99 (cargo clippy --workspace --all-targets -- -D warnings, 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/5737 **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/read-columns` --- ### 📝 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 - [`baabab5`](https://github.com/horizon-rust/horizon/commit/baabab598f758311fb025ac25d86cd6d5f319d7c) feat(mods): native server mods can read surface heights and columns - [`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) - [`3d685f4`](https://github.com/horizon-rust/horizon/commit/3d685f468fdb21604cfbe96f0b63b515f1decd11) 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 ### 📊 Changes **18 files changed** (+1604 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` (+3 -0) ➕ `crates/horizon-client/src/game/block_edits.rs` (+716 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+35 -20) ➕ `crates/horizon-client/src/game/native_world_columns.rs` (+71 -0) ➕ `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` (+39 -0) ➕ `tools/native-hook-fragments/native_edit_blocks.json` (+8 -0) ➕ `tools/native-hook-fragments/native_read_columns.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 #5735 (and so #5733): merge those first.** This PR's own change is `game/native_world_columns.rs`, the reads in `game/block_edits.rs`, the docs section and the fragment: +370 −24 against #5735. ## What and why Fixes #5736. Part of #5727, the hooks [Orbital Laser](https://github.com/Stink-O/orbital-laser) needs as a native mod (it reads the land under a strike to shape and colour its crater). It's useful to any server mod that surveys terrain, such as server-side minimaps, terraformers and structure placers. Today a mod reads one block per call, with no heights or tints. For server mods, in the level being ticked: - `native_surface_heights(dimension, columns, heightmap) -> Result<Vec<Option<i32>>, String>`: each column's height on a heightmap (`Heightmap.Types`), `None` where its chunk isn't loaded; at most 65,536 columns a call. - `native_read_columns(dimension, columns, heightmap, (below, above)) -> Result<NativeColumnBlocks, String>`: those heights, and each column's blocks from `below` under to `above` over it, bottom first. - The blocks come as a palette of names and `u16` indexes, with the biome's grass, foliage and water tints at the column's top. Thousands of columns fit in a call. - Blocks outside each chunk's own height, and every block of a column not loaded, read as air. - The tints are the biome's own at the column's top, not blended over the biome blend radius as the game draws them, so near a border they can differ from what players see by a few blocks. - It's bounded, with checked arithmetic: `below + above` must be 1 to the level's height, and a read at most 1,048,576 blocks (`MAX_READ`; it runs on the server tick, so a big area is read in pieces). Both return `Err` with the reason, reading nothing, as `native_edit_blocks` does: another dimension or a client of a server, a span or read out of bounds, so a mod can tell "ask for less" from "wrong level". docs/native-mods.md gets a "Column reads" section. They're helpers only: fragment `tools/native-hook-fragments/native_read_columns.json`. ## Kind - [x] feature ## Vanilla reference Horizon-only. Heights are `Heightmap.Types`; tints are `BiomeColors.getAverageGrassColor` / foliage / water. ## Other projects' code None from other projects. Ported from the author's own fork of Horizon (Stink-O/horizon, MIT): [cbceb3f0e](https://github.com/Stink-O/horizon/commit/cbceb3f0e), [a3ba97c94](https://github.com/Stink-O/horizon/commit/a3ba97c94), [20a8a553c](https://github.com/Stink-O/horizon/commit/20a8a553c). ## How it was tested - `cargo test -p horizon-client --bin horizon-client block_edits` → `test result: ok. 8 passed` (#5735's 4, and 4 new ones): - each heightmap's height (world surface, motion blocking, no leaves, ocean floor), with an empty column giving the bottom; - an unloaded column gives `None`; - blocks past the top, and in unloaded columns, read as air; - the size bound. - Stamped locally in a scratch worktree, not committed: `python3 tools/stamp_native_hooks.py` → `Stamped 6 fragment(s), through API 86`. - Orbital Laser's native build reads 3,000 columns × 24 blocks a call for the Sinkhole, the Payload, the Nuke and the Rod; its catch-up parity against the fork was clean (before this round's review fixes, which add the bounds). - `python3 tools/lan_e2e.py --check light --check walls --check chest` on this head (fast build): walls and chest PASS. light FAILED once ("border chunk: no position of the box is loaded on both sides", a check that the box's chunks load on both sides in time) 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:** last of #5733 → #5735 → #5737. - **Conflicts:** after #5735 merges, `git merge origin/main`. Fragment files: keep all. - **Risk:** read-only helpers that nothing calls unless a mod does. **Rollback:** revert before the stamp PR merges; after that, fix forward. ## Self-check **pr_ready** (Rust 1.99.1, `tools/pr_ready.py --quick --base native/edit-blocks` on DESKTOP-SNGRNA4-LINUX, against native/edit-blocks at c43496c5e, 13 min 48 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +396 −24 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 511 passed (21 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (40 s) | | tests: horizon-client | ✅ 1667 passed (12 min 39 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | CI's two clippy commands on Rust 1.99 (`cargo clippy --workspace --all-targets -- -D warnings`, `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:09 +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#6467
No description provided.