[PR #7559] Native mods: a level's blocks and time through LevelRef (#7387) #7667

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

📋 Pull Request Information

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

Base: main ← Head: modapi/level-reads


📝 Commits (3)

  • b978111 Native mods: a level's blocks and time through LevelRef (#7387)
  • 6a43ca6 Merge main into modapi/level-reads
  • 0f599d9 Merge remote-tracking branch 'hr/main' into modapi/level-reads

📊 Changes

6 files changed (+257 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+21 -0)
➕ crates/horizon-client/src/game/native_level_refs.rs (+97 -0)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+90 -0)
📝 docs/native-mods.md (+3 -0)
➕ tools/native-hook-fragments/level_reads.json (+45 -0)

📄 Description

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

Stacked on #7454 (draft until it merges; until then, review only the last commit).

Part of #7387, on top of #7454: LevelRef block states and world reads (the lines "block states and properties" and "world, time and rules", taken in the tracker).

What it adds

LevelRef methods (catalog entries with "receiver": "level", so each is also a plain Host method):

  • block_state(host, pos): the full state as /setblock takes it (minecraft:oak_stairs[facing=east,…]); block(host, pos): the name alone; block_property(host, pos, key).
  • is_loaded(host, pos), height(host) (lowest y and height).
  • game_time(host) and day_time(host).

They read any level the server has loaded, not only the one in place: the level in place directly, a parked one through levels.parked_world(dim). A block in a chunk that isn't loaded reads as None and never loads it. On a client, or with a handle of an earlier world open, everything reads None.

Files: game/native_level_refs.rs, the fragment tools/native-hook-fragments/level_reads.json, the generated Host files and a bullet in docs/native-mods.md ("Entity and level handles").

Proof

The probe bundle from #7454 (HEAD injection at Game::tick_mobs), run on this branch's fast build, server thread, offscreen, scratch homes. The player stands on a block, which a command later turns into east-facing oak stairs. The Nether is loaded and parked while the Overworld is in place.

ENTPROBE below=Some("minecraft:grass_block[snowy=false]") block=Some("minecraft:grass_block") facing=None nokey=None loaded=true far_loaded=false far_state=None sky=None height=Some((-64, 384)) game_time=Some(51) day_time=Some(51)
ENTPROBE below=Some("minecraft:oak_stairs[facing=east,half=bottom,shape=straight,waterlogged=false]") block=Some("minecraft:oak_stairs") facing=Some("east") nokey=None loaded=true far_loaded=false far_state=None sky=None height=Some((-64, 384)) game_time=Some(111) day_time=Some(111)
ENTPROBE nether loaded=true far=false column=[Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:netherrack"), Some("minecraft:netherrack")] height=Some((0, 256))
ENTPROBE nether loaded=true far=false column=[Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:netherrack"), Some("minecraft:netherrack")] height=Some((0, 256))
  • The block under the player reads before and after /setblock, with its properties.
  • A far, unloaded position reads None (far_loaded=false, far_state=None), and so does y=400 above the world.
  • The parked Nether reads netherrack and magma at its own height (0, 256) while the Overworld is in place.

pr_ready (tools/pr_ready.py --quick --base modapi/entity-handles on cachyos-x8664, against modapi/entity-handles at 7b77a5ec9, 3 min 51 s)

Check Result
Scope ✅ 6 files, +257 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (32 s)
rustfmt ✅ (6 s)
clippy ✅ (1 min 24 s)
tests: horizon-client, horizon-client-lib ✅ 2158 passed (1 min 26 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ✅ (20 s)
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)

🤖 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/7559 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `modapi/level-reads` --- ### 📝 Commits (3) - [`b978111`](https://github.com/horizon-rust/horizon/commit/b978111dddea704a7cf7d1e7cf7129a2ca445fbf) Native mods: a level's blocks and time through LevelRef (#7387) - [`6a43ca6`](https://github.com/horizon-rust/horizon/commit/6a43ca6d5afcf8d66232e5a25e155ed633abb2d1) Merge main into modapi/level-reads - [`0f599d9`](https://github.com/horizon-rust/horizon/commit/0f599d9d1370561741f86b0e9a9212813ab25d04) Merge remote-tracking branch 'hr/main' into modapi/level-reads ### 📊 Changes **6 files changed** (+257 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+21 -0) ➕ `crates/horizon-client/src/game/native_level_refs.rs` (+97 -0) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+90 -0) 📝 `docs/native-mods.md` (+3 -0) ➕ `tools/native-hook-fragments/level_reads.json` (+45 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. **Stacked on #7454** (draft until it merges; until then, review only the last commit). Part of #7387, on top of #7454: **LevelRef block states and world reads** (the lines "block states and properties" and "world, time and rules", taken in the tracker). ## What it adds `LevelRef` methods (catalog entries with `"receiver": "level"`, so each is also a plain `Host` method): - `block_state(host, pos)`: the full state as `/setblock` takes it (`minecraft:oak_stairs[facing=east,…]`); `block(host, pos)`: the name alone; `block_property(host, pos, key)`. - `is_loaded(host, pos)`, `height(host)` (lowest `y` and height). - `game_time(host)` and `day_time(host)`. They read **any level the server has loaded**, not only the one in place: the level in place directly, a parked one through `levels.parked_world(dim)`. A block in a chunk that isn't loaded reads as `None` and never loads it. On a client, or with a handle of an earlier world open, everything reads `None`. Files: `game/native_level_refs.rs`, the fragment `tools/native-hook-fragments/level_reads.json`, the generated Host files and a bullet in `docs/native-mods.md` ("Entity and level handles"). ## Proof The probe bundle from #7454 (HEAD injection at `Game::tick_mobs`), run on this branch's fast build, server thread, offscreen, scratch homes. The player stands on a block, which a command later turns into east-facing oak stairs. The Nether is loaded and parked while the Overworld is in place. ``` ENTPROBE below=Some("minecraft:grass_block[snowy=false]") block=Some("minecraft:grass_block") facing=None nokey=None loaded=true far_loaded=false far_state=None sky=None height=Some((-64, 384)) game_time=Some(51) day_time=Some(51) ENTPROBE below=Some("minecraft:oak_stairs[facing=east,half=bottom,shape=straight,waterlogged=false]") block=Some("minecraft:oak_stairs") facing=Some("east") nokey=None loaded=true far_loaded=false far_state=None sky=None height=Some((-64, 384)) game_time=Some(111) day_time=Some(111) ENTPROBE nether loaded=true far=false column=[Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:netherrack"), Some("minecraft:netherrack")] height=Some((0, 256)) ENTPROBE nether loaded=true far=false column=[Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:netherrack"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:magma_block"), Some("minecraft:netherrack"), Some("minecraft:netherrack")] height=Some((0, 256)) ``` - The block under the player reads before and after `/setblock`, with its properties. - A far, unloaded position reads `None` (`far_loaded=false`, `far_state=None`), and so does `y=400` above the world. - The parked Nether reads netherrack and magma at its own height (0, 256) while the Overworld is in place. **pr_ready** (`tools/pr_ready.py --quick --base modapi/entity-handles` on cachyos-x8664, against modapi/entity-handles at 7b77a5ec9, 3 min 51 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +257 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (32 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (1 min 24 s) | | tests: horizon-client, horizon-client-lib | ✅ 2158 passed (1 min 26 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (20 s) | | 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) | 🤖 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#7667
No description provided.