[PR #4289] [MERGED] Native mods: buttons, tooltips and item icons on mod screens #5545

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

📋 Pull Request Information

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

Base: main ← Head: native-mod-screen-widgets


📝 Commits (4)

  • 0c94687 Native mods: buttons, tooltips and item icons on mod screens
  • 3df5f5d Native mods: native_block, the block at a position (API 9)
  • d3d714e Native mods: native_data, a data file of the resources, content mods' included (API 9)
  • 2bc03ba Merge main; buttons, tooltips and item icons on mod screens are API 20

📊 Changes

6 files changed (+274 additions, -13 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+11 -4)
📝 crates/horizon-client/src/game/lan_stations.rs (+13 -0)
📝 crates/horizon-client/src/game/machines.rs (+13 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+218 -9)
📝 docs/native-mods.md (+4 -0)
📝 native-hooks.json (+15 -0)

📄 Description

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

Stacked on #4106 (on #4097, #4072, #4055, #3996): review only the last commit (0c9468753, +249 −12).

What and why

Fixes #4288. Part of #3911 (Mods): mod screens (#4106) get buttons, tooltips and item icons, and windows that aren't vanilla's, enough to draw a machine mod's window as it is (a title bar above the window, side tabs and buttons beside it, information icons on its right).

  • native_screen_click(block, data, at, right, &mut Option<i32>) (hook point): a press on a mod screen over no slot, inside or beside the window, becomes a menu button id. Horizon sends it as vanilla's ContainerButtonClick and the press goes no further (it throws nothing).
  • native_menu_button(pos, &mut ModBlockEntity, id) (hook point, server): runs it for the mod block entity behind the guest's open menu, after the checks of handleContainerButtonClick (that window, not a spectator, still valid). The entity is taken out for the call and put back with its setChanged, as for its tick (one shared put_back_mod_block_entity).
  • native_screen_tooltip(block, data, at, &mut Vec<String>) (hook point): lines under the mouse over no item, in vanilla's tooltip box (legacy colour codes work).
  • NativeScreen: width (the origin, the click area and hasClickedOutside follow it), inventory_x and own_labels (Horizon leaves the title and "Inventory" out). This changes #4106's struct before it is released.
  • Helpers: native_item(batch, item, at, size) (an item's icon, scaled as the advancement screen does), native_cursor, native_screen_title, native_block_property(pos, key), native_insert_item(pos, face, stack) (into a container through a side, as a hopper gives: a machine's auto-output).
  • API 9.

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 ServerboundContainerButtonClickPacket / ServerGamePacketListenerImpl.handleContainerButtonClick / AbstractContainerMenu.clickMenuButton, AbstractContainerScreen (imageWidth, hasClickedOutside) and HopperBlockEntity.addItem. Without a mod nothing changes.

Self-check

hook_points_stay_hookable and catalog_matches_hook_points cover the new hooks (in native-hooks.json). pr_ready --quick against origin/main at b1dfde280: fmt, clippy, Cargo.lock, public tree, Python tests (480) and client tests (1550) pass. Its scope counts the whole stack; this PR's own part is +249 −12.

Proof

The private GregTech test mod of #4097, now drawing GregTech CEu Modern's machine window 1:1 (172 wide, its title bar above with the machine's icon, side tabs, power / item auto-output / circuit buttons on the left, the information icon on the right), offscreen through horizon-ctl:

  • click-at on the power button: the macerator's workingEnabled goes to 0 and it stops; again, 1 and it works on.
  • click-at on auto-output: autoOutputItems goes to 1, and its dust moves into the chest behind it every 5 ticks (native_insert_item).
  • The mouse on the information icon: its tooltip lines, coloured.
    No screenshots here: the test mod draws with third-party textures that aren't Horizon's to publish.

Not covered: LAN guests (the same packet path the window's own client uses), a mod button's right click, scroll.

🤖 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/4289 **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-screen-widgets` --- ### 📝 Commits (4) - [`0c94687`](https://github.com/horizon-rust/horizon/commit/0c9468753d4118a4b44281317cf26c97250dfce5) Native mods: buttons, tooltips and item icons on mod screens - [`3df5f5d`](https://github.com/horizon-rust/horizon/commit/3df5f5d5c4837c94ac834b2bb9a78eda9248dad6) Native mods: native_block, the block at a position (API 9) - [`d3d714e`](https://github.com/horizon-rust/horizon/commit/d3d714e9eb8d429a84fcaf15d9d41bcb025f6bf1) Native mods: native_data, a data file of the resources, content mods' included (API 9) - [`2bc03ba`](https://github.com/horizon-rust/horizon/commit/2bc03baa6b24417c1a64e2f041bdb1ba8881b7c6) Merge main; buttons, tooltips and item icons on mod screens are API 20 ### 📊 Changes **6 files changed** (+274 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+11 -4) 📝 `crates/horizon-client/src/game/lan_stations.rs` (+13 -0) 📝 `crates/horizon-client/src/game/machines.rs` (+13 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+218 -9) 📝 `docs/native-mods.md` (+4 -0) 📝 `native-hooks.json` (+15 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, Claude Opus 5.5), not by Sylviromi personally. **Stacked on #4106 (on #4097, #4072, #4055, #3996): review only the last commit** (`0c9468753`, +249 −12). ## What and why Fixes #4288. Part of #3911 (Mods): mod screens (#4106) get buttons, tooltips and item icons, and windows that aren't vanilla's, enough to draw a machine mod's window as it is (a title bar above the window, side tabs and buttons beside it, information icons on its right). - **`native_screen_click(block, data, at, right, &mut Option<i32>)`** (hook point): a press on a mod screen over no slot, inside or beside the window, becomes a menu button id. Horizon sends it as vanilla's `ContainerButtonClick` and the press goes no further (it throws nothing). - **`native_menu_button(pos, &mut ModBlockEntity, id)`** (hook point, server): runs it for the mod block entity behind the guest's open menu, after the checks of `handleContainerButtonClick` (that window, not a spectator, still valid). The entity is taken out for the call and put back with its `setChanged`, as for its tick (one shared `put_back_mod_block_entity`). - **`native_screen_tooltip(block, data, at, &mut Vec<String>)`** (hook point): lines under the mouse over no item, in vanilla's tooltip box (legacy colour codes work). - **`NativeScreen`**: `width` (the origin, the click area and `hasClickedOutside` follow it), `inventory_x` and `own_labels` (Horizon leaves the title and "Inventory" out). This changes #4106's struct before it is released. - **Helpers**: `native_item(batch, item, at, size)` (an item's icon, scaled as the advancement screen does), `native_cursor`, `native_screen_title`, `native_block_property(pos, key)`, `native_insert_item(pos, face, stack)` (into a container through a side, as a hopper gives: a machine's auto-output). - API 9. ## 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 `ServerboundContainerButtonClickPacket` / `ServerGamePacketListenerImpl.handleContainerButtonClick` / `AbstractContainerMenu.clickMenuButton`, `AbstractContainerScreen` (`imageWidth`, `hasClickedOutside`) and `HopperBlockEntity.addItem`. Without a mod nothing changes. ## Self-check `hook_points_stay_hookable` and `catalog_matches_hook_points` cover the new hooks (in `native-hooks.json`). **pr_ready** `--quick` against origin/main at b1dfde280: fmt, clippy, Cargo.lock, public tree, Python tests (480) and client tests (1550) pass. Its scope counts the whole stack; this PR's own part is +249 −12. ## Proof The private GregTech test mod of #4097, now drawing GregTech CEu Modern's machine window 1:1 (172 wide, its title bar above with the machine's icon, side tabs, power / item auto-output / circuit buttons on the left, the information icon on the right), offscreen through `horizon-ctl`: - `click-at` on the power button: the macerator's `workingEnabled` goes to 0 and it stops; again, 1 and it works on. - `click-at` on auto-output: `autoOutputItems` goes to 1, and its dust moves into the chest behind it every 5 ticks (`native_insert_item`). - The mouse on the information icon: its tooltip lines, coloured. No screenshots here: the test mod draws with third-party textures that aren't Horizon's to publish. Not covered: LAN guests (the same packet path the window's own client uses), a mod button's right click, scroll. 🤖 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:13:19 +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#5545
No description provided.