[PR #7319] Native mods: block textures for client mods (native_block_sprites, WorldDrawn::block_sprites) #7489

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7319
Author: @Stink-O
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: native/block-sprites


📝 Commits (8)

📊 Changes

14 files changed (+847 additions, -12 deletions)

View changed files

📝 crates/horizon-client-render/src/assets.rs (+6 -0)
➕ crates/horizon-client-render/src/block_sprites.rs (+432 -0)
📝 crates/horizon-client-render/src/gfx.rs (+39 -2)
📝 crates/horizon-client-render/src/gfx/native_render.rs (+205 -0)
📝 crates/horizon-client-render/src/lib.rs (+1 -0)
📝 crates/horizon-client-render/src/mesher.rs (+34 -0)
📝 crates/horizon-client/src/client_lib.rs (+6 -6)
📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+9 -0)
➕ crates/horizon-client/src/game/native_block_sprites.rs (+40 -0)
📝 crates/horizon-client/src/mod_api.rs (+4 -1)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+21 -0)
📝 docs/native-mods.md (+35 -3)
➕ tools/native-hook-fragments/native_block_sprites.json (+14 -0)

📄 Description

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

What and why

Fixes #7318.

Native client mods can now draw blocks in their own pass with the player's own block textures, resource packs included, sampled the way the terrain samples them. This is part of making Orbital Laser native: its Hurricane throws blocks that it draws as voxels in its post pass. The same pieces work for any mod that draws blocks outside the chunk mesh, such as previews, ghost builds or debris.

  • block_sprites::Lookup (horizon-client-render). For a block state such as oak_log[axis=x], it gives what the model draws on each of the six sides, as the mesher bakes it:

    • each face's sprite: its array and layer, cut by the device's split;
    • where the face lies on the side, and how deep;
    • the affine map from the side to the sprite's UVs, rotations and mirrors included;
    • its tint source, from MeshTables::tint_source, a source-level twin of default_tint that matches what the chunk mesher colours with;
    • whether it is cut out, translucent or animated.

    It also gives the model's particle sprite and whether the model is a plain cube. Fluids give their still texture on every side.

  • Helpers native_block_sprites(blocks), native_texture_sprites(textures) and native_block_sprites_version(). They come from a helper-only fragment, tools/native-hook-fragments/native_block_sprites.json, and cargo run -p xtask -- mod-api regenerated the Host. The version is a new RenderAssets::generation, which counts resource loads.

  • WorldDrawn::block_sprites (BlockSpriteArrays). The field is additive, since WorldDrawn is #[non_exhaustive]. It holds:

    • the eight D2Array views as the terrain binds them, with the Mipmap Levels option's levels (the renderer keeps them now, instead of making them in rebuild_terrain_group);
    • the device's split (Renderer::sprite_split);
    • the layer size;
    • a new nearest repeating sampler, plus the terrain's own filtered one.
  • docs/native-mods.md: a "Block textures" section, and the world_drawn entry names the arrays.

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 (the native mod API)
  • docs

Vanilla reference

Horizon-only (the native mod API). The faces are the mesher's own baked faces (StateModels::collect), and the tint sources follow the mesher's Tint (BlockColors.createDefault).

Other projects' code

none

Verify

cargo +1.99 test -p horizon-client-render --lib -- native_render block_sprites
HORIZON_TEST_RESOURCES=.local/horizon-client/26.3 cargo +1.99 test -p horizon-client-render --lib -- --ignored real_blocks_name_their_sprites
python3 tools/pr_ready.py --base origin/main
test block_sprites::tests::real_blocks_name_their_sprites ... ignored, requires prepared models/textures in HORIZON_TEST_RESOURCES
test block_sprites::tests::a_faces_texture_runs_across_its_side ... ok
test gfx::native_render::tests::needs_accumulate_in_mod_order ... ok
test gfx::native_render::tests::a_pass_samples_a_sprite_layer_sharp ... ok
test result: ok. 4 passed; 0 failed; 1 ignored

(with --ignored and HORIZON_TEST_RESOURCES)
test result: ok. 1 passed; 0 failed; 0 ignored

Exercised

Orbital Laser's native bundle runs on this branch, with the fragment stamped locally. It gives its Hurricane the arrays from WorldDrawn::block_sprites and the faces from block_sprites::Lookup at the renderer's split, and refreshes them on native_block_sprites_version. In a world the pass compiles, and the flying blocks wear the game's own textures: grass blocks with their tinted overlay, foliage-tinted leaves, a birch log on its side. The log has no errors.

Self-check

pr_ready (tools/pr_ready.py on DESKTOP-SNGRNA4-LINUX, against origin/main at ab2d9f964, 5 min 21 s)

Check Result
Scope ⚠️ 14 files, +845 −10; 821 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (36 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 44 s)
tests: horizon-client, horizon-client-lib, horizon-client-render ❌ 2119 passed (2 min 15 s)
doc tests ✅ 0 passed (8 s)
content root tests ✅ 24 passed
mod API up to date ✅ (30 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): 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)

The ❌ on the tests is a SIGSEGV in the horizon-client-render test binary after every test reports ok. It happens on origin/main at ab2d9f964 too, on this machine, in two of three runs of cargo test -p horizon-client-render --lib. It also crashed one of two runs here with the new GPU test skipped. All 1,155 tests pass, the new ones included.

Rechecked on Rust 1.99 after merging main at 2105feb78: rustfmt and clippy clean, cargo test -p xtask mod_api 17 passed, the new tests 4 passed and 1 ignored, and cargo run -p xtask -- mod-api leaves the generated Host unchanged.

Merge order: this one alone; no other pull request depends on it. The fragment is helper-only, so stamping assigns the next API number.

🤖 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/7319 **Author:** [@Stink-O](https://github.com/Stink-O) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `native/block-sprites` --- ### 📝 Commits (8) - [`bef1098`](https://github.com/horizon-rust/horizon/commit/bef10987b39f246f8707157b080a90f6d3f0f8c4) Native mods: block textures for client mods (native_block_sprites, WorldDrawn::block_sprites) - [`7548b0f`](https://github.com/horizon-rust/horizon/commit/7548b0ffd84d62e31a9b64341909cbd86cdccce0) Merge remote-tracking branch 'origin/main' into native/block-sprites - [`7c236bd`](https://github.com/horizon-rust/horizon/commit/7c236bdef3a85fe0975248c6577ffe1f2514df79) Merge remote-tracking branch 'origin/main' into native/block-sprites - [`3fa6070`](https://github.com/horizon-rust/horizon/commit/3fa60709e251a8ce6d7eaed83b2ecdbb09a50d43) Merge branch 'main' of https://github.com/ludovic111/horizon into native/block-sprites - [`696a760`](https://github.com/horizon-rust/horizon/commit/696a760e853efc6a1f00d720dcf64dc195ae4dcf) Merge branch 'main' of https://github.com/ludovic111/horizon into native/block-sprites - [`e348ae8`](https://github.com/horizon-rust/horizon/commit/e348ae8e91c3d74c25ae988627e0b5dd14afbf1e) Merge main (e5a138fac) into native/block-sprites - [`8dd32dc`](https://github.com/horizon-rust/horizon/commit/8dd32dcb1344c1284a81ccaac6039d08328f319b) Merge main (2105feb78) into native/block-sprites - [`d003ea8`](https://github.com/horizon-rust/horizon/commit/d003ea875a33cbfcca1386e0515f66e1b0bfae2c) Merge main (0c7b5b61a) into native/block-sprites ### 📊 Changes **14 files changed** (+847 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/assets.rs` (+6 -0) ➕ `crates/horizon-client-render/src/block_sprites.rs` (+432 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+39 -2) 📝 `crates/horizon-client-render/src/gfx/native_render.rs` (+205 -0) 📝 `crates/horizon-client-render/src/lib.rs` (+1 -0) 📝 `crates/horizon-client-render/src/mesher.rs` (+34 -0) 📝 `crates/horizon-client/src/client_lib.rs` (+6 -6) 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+9 -0) ➕ `crates/horizon-client/src/game/native_block_sprites.rs` (+40 -0) 📝 `crates/horizon-client/src/mod_api.rs` (+4 -1) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+21 -0) 📝 `docs/native-mods.md` (+35 -3) ➕ `tools/native-hook-fragments/native_block_sprites.json` (+14 -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 #7318. Native client mods can now draw blocks in their own pass with the player's own block textures, resource packs included, sampled the way the terrain samples them. This is part of making Orbital Laser native: its Hurricane throws blocks that it draws as voxels in its post pass. The same pieces work for any mod that draws blocks outside the chunk mesh, such as previews, ghost builds or debris. - **`block_sprites::Lookup`** (horizon-client-render). For a block state such as `oak_log[axis=x]`, it gives what the model draws on each of the six sides, as the mesher bakes it: - each face's sprite: its array and layer, cut by the device's split; - where the face lies on the side, and how deep; - the affine map from the side to the sprite's UVs, rotations and mirrors included; - its tint source, from `MeshTables::tint_source`, a source-level twin of `default_tint` that matches what the chunk mesher colours with; - whether it is cut out, translucent or animated. It also gives the model's particle sprite and whether the model is a plain cube. Fluids give their still texture on every side. - **Helpers** `native_block_sprites(blocks)`, `native_texture_sprites(textures)` and `native_block_sprites_version()`. They come from a helper-only fragment, `tools/native-hook-fragments/native_block_sprites.json`, and `cargo run -p xtask -- mod-api` regenerated the `Host`. The version is a new `RenderAssets::generation`, which counts resource loads. - **`WorldDrawn::block_sprites`** (`BlockSpriteArrays`). The field is additive, since `WorldDrawn` is `#[non_exhaustive]`. It holds: - the eight `D2Array` views as the terrain binds them, with the Mipmap Levels option's levels (the renderer keeps them now, instead of making them in `rebuild_terrain_group`); - the device's split (`Renderer::sprite_split`); - the layer size; - a new nearest repeating sampler, plus the terrain's own filtered one. - **docs/native-mods.md**: a "Block textures" section, and the `world_drawn` entry names the arrays. ## 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 - [x] tooling: tools, CI, tests, harnesses (the native mod API) - [ ] docs ## Vanilla reference Horizon-only (the native mod API). The faces are the mesher's own baked faces (`StateModels::collect`), and the tint sources follow the mesher's `Tint` (`BlockColors.createDefault`). ## Other projects' code none ## Verify ```sh cargo +1.99 test -p horizon-client-render --lib -- native_render block_sprites HORIZON_TEST_RESOURCES=.local/horizon-client/26.3 cargo +1.99 test -p horizon-client-render --lib -- --ignored real_blocks_name_their_sprites python3 tools/pr_ready.py --base origin/main ``` ``` test block_sprites::tests::real_blocks_name_their_sprites ... ignored, requires prepared models/textures in HORIZON_TEST_RESOURCES test block_sprites::tests::a_faces_texture_runs_across_its_side ... ok test gfx::native_render::tests::needs_accumulate_in_mod_order ... ok test gfx::native_render::tests::a_pass_samples_a_sprite_layer_sharp ... ok test result: ok. 4 passed; 0 failed; 1 ignored (with --ignored and HORIZON_TEST_RESOURCES) test result: ok. 1 passed; 0 failed; 0 ignored ``` ## Exercised Orbital Laser's native bundle runs on this branch, with the fragment stamped locally. It gives its Hurricane the arrays from `WorldDrawn::block_sprites` and the faces from `block_sprites::Lookup` at the renderer's split, and refreshes them on `native_block_sprites_version`. In a world the pass compiles, and the flying blocks wear the game's own textures: grass blocks with their tinted overlay, foliage-tinted leaves, a birch log on its side. The log has no errors. ## Self-check **pr_ready** (`tools/pr_ready.py` on DESKTOP-SNGRNA4-LINUX, against origin/main at ab2d9f964, 5 min 21 s) | Check | Result | | --- | --- | | Scope | ⚠️ 14 files, +845 −10; 821 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (36 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 44 s) | | tests: horizon-client, horizon-client-lib, horizon-client-render | ❌ 2119 passed (2 min 15 s) | | doc tests | ✅ 0 passed (8 s) | | content root tests | ✅ 24 passed | | mod API up to date | ✅ (30 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): 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) | The ❌ on the tests is a SIGSEGV in the `horizon-client-render` test binary after every test reports ok. It happens on `origin/main` at ab2d9f964 too, on this machine, in two of three runs of `cargo test -p horizon-client-render --lib`. It also crashed one of two runs here with the new GPU test skipped. All 1,155 tests pass, the new ones included. Rechecked on Rust 1.99 after merging main at 2105feb78: rustfmt and clippy clean, `cargo test -p xtask mod_api` 17 passed, the new tests 4 passed and 1 ignored, and `cargo run -p xtask -- mod-api` leaves the generated `Host` unchanged. Merge order: this one alone; no other pull request depends on it. The fragment is helper-only, so stamping assigns the next API number. 🤖 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>
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#7489
No description provided.