[PR #4106] [MERGED] Native mods: mod-drawn screens for mod blocks (own GUI textures, layout, data) #5421

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4106
Author: @Sylviromi
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: native-mod-screens


📝 Commits (7)

  • 7df9ed0 Native mods: screens for mod blocks, drawn with the mod's GUI textures
  • 7aaa688 Merge branch 'native-mod-neighbours' into native-mod-screens
  • 0bebf89 Merge branch 'native-mod-neighbours' into native-mod-screens
  • c89bf62 Native mods: a mod screen takes data only for its own window
  • a1e0330 Merge branch 'native-mod-neighbours' into native-mod-screens
  • 7255ecd Native mods: mod screens are API 8
  • a14cac7 Merge main; mod screens are API 19; the server menu skips the slots a mod screen hides

📊 Changes

11 files changed (+388 additions, -6 deletions)

View changed files

📝 crates/horizon-client-render/src/hud.rs (+35 -0)
📝 crates/horizon-client/src/game.rs (+13 -3)
📝 crates/horizon-client/src/game/lan_actions.rs (+4 -0)
📝 crates/horizon-client/src/game/machines.rs (+3 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+257 -1)
📝 crates/horizon-client/src/game/recipe_book.rs (+2 -1)
📝 crates/horizon-client/src/game/remote.rs (+2 -0)
📝 crates/horizon-client/src/lan/containers.rs (+21 -0)
📝 crates/horizon-client/src/lan/menu.rs (+37 -1)
📝 docs/native-mods.md (+4 -0)
📝 native-hooks.json (+10 -0)

📄 Description

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

Stacked on #4097 (on #4072, #4055, #3996): review only the last commit (7df9ed054, +282 −11).

What and why

Fixes #4105. Part of #3911 (Mods): screens a mod draws for its blocks' menus (gaps "M, menus and screens" and "U, client UI" in #1854), on the client only: the server's menu and the protocol are unchanged.

  • Mod GUI textures (horizon-client-render/src/hud.rs): a content mod's assets/<namespace>/textures/gui/** become GUI sprites named <namespace>:gui/...; vanilla's names and a mod's other textures are as they were.
  • native_screen(block, &mut Option<NativeScreen>) (hook point): when a menu opens on a mod block, the mod lays its screen out: its height (176 wide), each container slot's position or None to hide it (hidden slots can't be clicked), and the inventory's first row.
  • native_screen_draw(block, data, batch, origin) (hook point): the mod draws the screen over a plain panel with the slots' frames and under the items and labels, from the menu's data slots, which the client now keeps for a mod screen (ContainerSetData).
  • native_sprite(batch, name, src, dst), native_sprite_size(name) (helpers): any part of a sprite, stretched, so a mod can draw nine-slice panels, bars filling by a fraction, and icons.
  • The open screen's height, slot positions, the player inventory's row and its hidden slots go through slot_position, slots, screen_height; a mod screen has no recipe book.

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
  • docs

Vanilla reference

Horizon-only (the native mod API), following AbstractContainerScreen (imageHeight, Slot.x/y, titleLabelX/Y, inventoryLabelY) and ClientboundContainerSetDataPacket. Without a mod nothing changes.

Self-check

New test hud::tests::a_content_mods_gui_textures_are_sprites_under_its_namespace; hook_points_stay_hookable and catalog_matches_hook_points cover the new hooks (in native-hooks.json). pr_ready --quick against origin/main at 829c4021a: fmt, clippy, Cargo.lock, public tree and Python tests pass; client tests 688 passed, 1 failed (the axolotl test of #3840, only with prepared resources; passes in CI). Its scope counts the whole stack; this PR's own part is +282 −11.

Proof

The GregTech-style test mod of #4097 (local), now drawing its own screens: a nine-slice panel, an energy bar filling from the bottom, a fuel gauge, a progress bar filling left to right, slot icons, and lines of text from the data slots ("15,998 / 16,000 EU", "Using 2 EU/t", "Generating 32 EU/t", "No power"). Offscreen through horizon-ctl: the macerator's and the generator's screens open with their own layouts (the generator shows its fuel slot only), their bars and text follow the machines live, and items move in and out of the shown slots. No screenshots here: the private test mod draws them with third-party textures that aren't Horizon's to publish.

Not covered: LAN guests and servers' players (the same client code, and the server is unchanged), a resource pack over a mod's GUI textures.

🤖 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/4106 **Author:** [@Sylviromi](https://github.com/Sylviromi) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `native-mod-screens` --- ### 📝 Commits (7) - [`7df9ed0`](https://github.com/horizon-rust/horizon/commit/7df9ed0545033325e714facda15a4f93e550b363) Native mods: screens for mod blocks, drawn with the mod's GUI textures - [`7aaa688`](https://github.com/horizon-rust/horizon/commit/7aaa68865ffce53e91eafe18290f5bb6582e6ad0) Merge branch 'native-mod-neighbours' into native-mod-screens - [`0bebf89`](https://github.com/horizon-rust/horizon/commit/0bebf892201c1aeffb0bc64b23d402f436beb92a) Merge branch 'native-mod-neighbours' into native-mod-screens - [`c89bf62`](https://github.com/horizon-rust/horizon/commit/c89bf6241d07449d02298f4dd900e80e6d6f7911) Native mods: a mod screen takes data only for its own window - [`a1e0330`](https://github.com/horizon-rust/horizon/commit/a1e033003a79d798c2205753e3c05b9766c2cc78) Merge branch 'native-mod-neighbours' into native-mod-screens - [`7255ecd`](https://github.com/horizon-rust/horizon/commit/7255ecd851e8046080acd291dd6d7ff577ccd552) Native mods: mod screens are API 8 - [`a14cac7`](https://github.com/horizon-rust/horizon/commit/a14cac7f7c0d7f429ffabe598791b8bf9363b758) Merge main; mod screens are API 19; the server menu skips the slots a mod screen hides ### 📊 Changes **11 files changed** (+388 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/hud.rs` (+35 -0) 📝 `crates/horizon-client/src/game.rs` (+13 -3) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+4 -0) 📝 `crates/horizon-client/src/game/machines.rs` (+3 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+257 -1) 📝 `crates/horizon-client/src/game/recipe_book.rs` (+2 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+2 -0) 📝 `crates/horizon-client/src/lan/containers.rs` (+21 -0) 📝 `crates/horizon-client/src/lan/menu.rs` (+37 -1) 📝 `docs/native-mods.md` (+4 -0) 📝 `native-hooks.json` (+10 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, Claude Opus 5.5), not by Sylviromi personally. **Stacked on #4097 (on #4072, #4055, #3996): review only the last commit** (`7df9ed054`, +282 −11). ## What and why Fixes #4105. Part of #3911 (Mods): screens a mod draws for its blocks' menus (gaps "M, menus and screens" and "U, client UI" in #1854), on the client only: the server's menu and the protocol are unchanged. - **Mod GUI textures** (`horizon-client-render/src/hud.rs`): a content mod's `assets/<namespace>/textures/gui/**` become GUI sprites named `<namespace>:gui/...`; vanilla's names and a mod's other textures are as they were. - **`native_screen(block, &mut Option<NativeScreen>)`** (hook point): when a menu opens on a mod block, the mod lays its screen out: its height (176 wide), each container slot's position or `None` to hide it (hidden slots can't be clicked), and the inventory's first row. - **`native_screen_draw(block, data, batch, origin)`** (hook point): the mod draws the screen over a plain panel with the slots' frames and under the items and labels, from the menu's data slots, which the client now keeps for a mod screen (`ContainerSetData`). - **`native_sprite(batch, name, src, dst)`, `native_sprite_size(name)`** (helpers): any part of a sprite, stretched, so a mod can draw nine-slice panels, bars filling by a fraction, and icons. - The open screen's height, slot positions, the player inventory's row and its hidden slots go through `slot_position`, `slots`, `screen_height`; a mod screen has no recipe book. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (the native mod API), following `AbstractContainerScreen` (`imageHeight`, `Slot.x`/`y`, `titleLabelX/Y`, `inventoryLabelY`) and `ClientboundContainerSetDataPacket`. Without a mod nothing changes. ## Self-check New test `hud::tests::a_content_mods_gui_textures_are_sprites_under_its_namespace`; `hook_points_stay_hookable` and `catalog_matches_hook_points` cover the new hooks (in `native-hooks.json`). **pr_ready** `--quick` against origin/main at 829c4021a: fmt, clippy, Cargo.lock, public tree and Python tests pass; client tests 688 passed, 1 failed (the axolotl test of #3840, only with prepared resources; passes in CI). Its scope counts the whole stack; this PR's own part is +282 −11. ## Proof The GregTech-style test mod of #4097 (local), now drawing its own screens: a nine-slice panel, an energy bar filling from the bottom, a fuel gauge, a progress bar filling left to right, slot icons, and lines of text from the data slots ("15,998 / 16,000 EU", "Using 2 EU/t", "Generating 32 EU/t", "No power"). Offscreen through `horizon-ctl`: the macerator's and the generator's screens open with their own layouts (the generator shows its fuel slot only), their bars and text follow the machines live, and items move in and out of the shown slots. No screenshots here: the private test mod draws them with third-party textures that aren't Horizon's to publish. Not covered: LAN guests and servers' players (the same client code, and the server is unchanged), a resource pack over a mod's GUI textures. 🤖 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 05:12:29 +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#5421
No description provided.