[PR #5741] [MERGED] feat(mods): native mods can open custom menus #6468

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/5741
Author: @Stink-O
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/mod-screens


📝 Commits (10+)

📊 Changes

6 files changed (+154 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+9 -0)
📝 crates/horizon-client/src/game/agent.rs (+1 -0)
📝 crates/horizon-client/src/game/control.rs (+1 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+136 -0)
📝 crates/horizon-client/src/game/screens.rs (+2 -1)
➕ tools/native-hook-fragments/native_mod_screen.json (+5 -0)

📄 Description

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

Stacked on #5617, which is stacked on #5616 (Sylviromi's screen hooks, #5543). Merge those first. Until they
merge, this diff also shows their commits and their two fragments (screen_key_input.json,
screen_mouse_scrolled.json). This PR's own change is f641477ff and eb47e82ba: Screen::Mod, three helpers, two
drawing helpers, a test and native_mod_screen.json. It does not depend on #5731.

What and why

Fixes #5740. Part of #5727, the hooks Orbital Laser needs as a native mod
(its laser wheel). Useful to any client mod that wants a screen of its own: settings, radial menus, editors, maps.
Today a native mod's screens are only its blocks' menus, and the screen hooks (#5543) can draw over a screen but
can't open one.

  • native_mod_screen_open(mod_id) -> bool opens the mod's own screen over the world (Screen::Mod). It returns
    false where the screen hooks couldn't draw it: while another screen is open (or another mod's), over the title
    screen, a book, a sign editor, a dialog or a prompt, while the world loads, with no player, and anywhere but the
    window's own client (the server thread, a dedicated server, a LAN guest's swap). It returns true if this mod's is
    already open.
  • A gamepad can close it (B, Start) but not click on it: its clicks don't reach the mouse hooks.
  • native_mod_screen() says whose screen is open. native_mod_screen_close(mod_id) closes it. So do Escape and any
    screen that replaces it.
  • The mouse is freed while it's open. It doesn't pause a single-player game, like the inventory.
  • Every mod's own screen has the NativeScreenView.id mod. A mod's screen hooks check that
    native_mod_screen() is its own before drawing.
  • It draws nothing itself. The mod draws in native_screen_render_post (#5571) and takes clicks
    (native_screen_mouse_button_pressed_pre, #5578), the wheel (#5616), and keys and typing (#5617). So horizon-ctl's
    click-at, key and type reach it too.
  • Two drawing helpers beside native_fill:
    • native_quad(batch, points, argb): wedges, slanted bars; filled as native_fill fills, through
      HudBatch::fill_quad.
    • native_item_model(batch, item, model, at, size): an item's icon drawn with another item_model, as a content
      mod's own icons are.

It's a helper set only: fragment tools/native-hook-fragments/native_mod_screen.json. No API number is edited.

Kind

  • feature

Vanilla reference

Horizon-only: a mod's own Screen, as a NeoForge mod opens one with Minecraft.setScreen.

Other projects' code

None from other projects. Ported from the author's own fork of Horizon (Stink-O/horizon, MIT):
ae531730c (ui.show),
848a0686c, reshaped onto the screen hooks.

How it was tested

  • cargo test -p horizon-client --bin horizon-client native_hooks::tests::a_mod_screen_opens_only_over_the_world
    → test result: ok. 1 passed. The open rules (in mod_screen_opens): it opens only over the world, never over another
    screen, the title screen or another mod's, and opening it again changes nothing.
  • cargo test -p horizon-client --bin horizon-client native_hooks → test result: ok. 18 passed.
  • Orbital Laser's wheel as a native mod on this branch, offscreen with horizon-ctl in a scratch home, against the
    fork's wheel. It matched pixel for pixel on the wheel and step by step: opened with R, its pages, picking a laser,
    toggles, typing a fly speed, Escape. That was before native_quad moved to fill_quad, which draws the
    same solid colour from the HUD atlas's white.
  • Stamped locally in a scratch worktree, not committed: python3 tools/stamp_native_hooks.py → Stamped 7 fragment(s), through API 87 (main's 4 pending, #5616's and #5617's, then this).

For the merge

  • #5617's review findings (rdbtCVS's and Aria's agents): a cancelled key drops its surviving characters; the
    control socket's \b sentinel reaches the char hook; the docs say "window only". They're #5617's to fix, and this
    PR picks the fixes up when #5617 merges, with nothing to change here. None of them breaks a mod screen: it has no
    text box of its own, and a mod takes its typing from the char hook, which is still told about every character. The
    \b sentinel only reaches a mod through horizon-ctl's type, and the fix turns it back into a Backspace key.
    Orbital Laser's wheel types its fly speed exactly that way.
  • Merge order: #5616 → #5617 → this. Merged first, this would carry their fragments and stamp them under this
    PR's merge.
  • Conflicts: #5731 adds a Game field and its initialiser at the same two lines of game.rs (after
    native_shaders): keep both. After #5617 merges, git merge origin/main drops its commits from this diff. Main
    was merged in on 2026-11-01 (5edb339a7).
  • Risk: low: a new Screen variant that no vanilla path opens. Rollback: revert before the stamp PR
    merges; after that, fix forward.

Self-check

pr_ready (Rust 1.99.1, tools/pr_ready.py --quick on DESKTOP-SNGRNA4-LINUX, against origin/main at bb03a6b2e, 2 min 14 s)

Check Result
Scope ⚠️ 10 files, +564 −57; 621 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (29 s)
rustfmt ✅ (6 s)
clippy ✅ (43 s)
tests: horizon-client ✅ 1677 passed (54 s)
doc tests ✅ 0 passed (2 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/5741 **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/mod-screens` --- ### 📝 Commits (10+) - [`f641477`](https://github.com/horizon-rust/horizon/commit/f641477ff6203a32a92f54165d7c4133d51ca837) feat(mods): native mods can open custom menus - [`07901ba`](https://github.com/horizon-rust/horizon/commit/07901bae47c9573f66db0cb0647829b9c397bc74) Merge main into #5741 (both sides' hook tests kept) - [`6705843`](https://github.com/horizon-rust/horizon/commit/670584316e2f6916edcdfc74663a04690e636ad1) Merge main into #5741 - [`eb47e82`](https://github.com/horizon-rust/horizon/commit/eb47e82bac8c089952f0099da92d83e1110c8f6b) fix(mods): native_quad fills as native_fill does; the mod screen's rules tested and documented - [`ad13187`](https://github.com/horizon-rust/horizon/commit/ad13187cf76ace492bb89b390d188a4da11ffc83) Merge #5617's current head into #5741 - [`713798e`](https://github.com/horizon-rust/horizon/commit/713798e681302fdc394d95084a07445f9e8082a6) Merge main into #5741 (after #5616) - [`c107eeb`](https://github.com/horizon-rust/horizon/commit/c107eeb1a4b4a2e3239ce80a04c36254c1a1ed4d) fix(mods): a mod screen opens only where the screen hooks can draw it - [`13327b6`](https://github.com/horizon-rust/horizon/commit/13327b6e0a0b9986dbdb2b88f1a3a88370db0c33) refactor(mods): the mod screen's Game field after native_net - [`55f58be`](https://github.com/horizon-rust/horizon/commit/55f58be2892d54cfad74266b1a209b5f3ce5371e) Merge #5617's approved head into #5741 - [`a498176`](https://github.com/horizon-rust/horizon/commit/a498176bd717f16f09035676613efd2deb9927a0) Merge main into #5741 ### 📊 Changes **6 files changed** (+154 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+9 -0) 📝 `crates/horizon-client/src/game/agent.rs` (+1 -0) 📝 `crates/horizon-client/src/game/control.rs` (+1 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+136 -0) 📝 `crates/horizon-client/src/game/screens.rs` (+2 -1) ➕ `tools/native-hook-fragments/native_mod_screen.json` (+5 -0) </details> ### 📄 Description > 🤖 Opened by Stink-O's AI agent (Claude Code, Claude Opus 5.5), not by Stink-O personally. **Stacked on #5617, which is stacked on #5616 (Sylviromi's screen hooks, #5543). Merge those first.** Until they merge, this diff also shows their commits and their two fragments (`screen_key_input.json`, `screen_mouse_scrolled.json`). This PR's own change is f641477ff and eb47e82ba: `Screen::Mod`, three helpers, two drawing helpers, a test and `native_mod_screen.json`. It does not depend on #5731. ## What and why Fixes #5740. Part of #5727, the hooks [Orbital Laser](https://github.com/Stink-O/orbital-laser) needs as a native mod (its laser wheel). Useful to any client mod that wants a screen of its own: settings, radial menus, editors, maps. Today a native mod's screens are only its blocks' menus, and the screen hooks (#5543) can draw over a screen but can't open one. - `native_mod_screen_open(mod_id) -> bool` opens the mod's own screen over the world (`Screen::Mod`). It returns false where the screen hooks couldn't draw it: while another screen is open (or another mod's), over the title screen, a book, a sign editor, a dialog or a prompt, while the world loads, with no player, and anywhere but the window's own client (the server thread, a dedicated server, a LAN guest's swap). It returns true if this mod's is already open. - A gamepad can close it (B, Start) but not click on it: its clicks don't reach the mouse hooks. - `native_mod_screen()` says whose screen is open. `native_mod_screen_close(mod_id)` closes it. So do Escape and any screen that replaces it. - The mouse is freed while it's open. It doesn't pause a single-player game, like the inventory. - **Every mod's own screen has the `NativeScreenView.id` `mod`.** A mod's screen hooks check that `native_mod_screen()` is its own before drawing. - It draws nothing itself. The mod draws in `native_screen_render_post` (#5571) and takes clicks (`native_screen_mouse_button_pressed_pre`, #5578), the wheel (#5616), and keys and typing (#5617). So horizon-ctl's `click-at`, `key` and `type` reach it too. - Two drawing helpers beside `native_fill`: - `native_quad(batch, points, argb)`: wedges, slanted bars; filled as `native_fill` fills, through `HudBatch::fill_quad`. - `native_item_model(batch, item, model, at, size)`: an item's icon drawn with another `item_model`, as a content mod's own icons are. It's a helper set only: fragment `tools/native-hook-fragments/native_mod_screen.json`. No API number is edited. ## Kind - [x] feature ## Vanilla reference Horizon-only: a mod's own `Screen`, as a NeoForge mod opens one with `Minecraft.setScreen`. ## Other projects' code None from other projects. Ported from the author's own fork of Horizon (Stink-O/horizon, MIT): [ae531730c](https://github.com/Stink-O/horizon/commit/ae531730c) (`ui.show`), [848a0686c](https://github.com/Stink-O/horizon/commit/848a0686c), reshaped onto the screen hooks. ## How it was tested - `cargo test -p horizon-client --bin horizon-client native_hooks::tests::a_mod_screen_opens_only_over_the_world` → `test result: ok. 1 passed`. The open rules (in `mod_screen_opens`): it opens only over the world, never over another screen, the title screen or another mod's, and opening it again changes nothing. - `cargo test -p horizon-client --bin horizon-client native_hooks` → `test result: ok. 18 passed`. - Orbital Laser's wheel as a native mod on this branch, offscreen with horizon-ctl in a scratch home, against the fork's wheel. It matched pixel for pixel on the wheel and step by step: opened with R, its pages, picking a laser, toggles, typing a fly speed, Escape. That was before `native_quad` moved to `fill_quad`, which draws the same solid colour from the HUD atlas's white. - Stamped locally in a scratch worktree, not committed: `python3 tools/stamp_native_hooks.py` → `Stamped 7 fragment(s), through API 87 (main's 4 pending, #5616's and #5617's, then this)`. ## For the merge - **#5617's review findings** (rdbtCVS's and Aria's agents): a cancelled key drops its surviving characters; the control socket's `\b` sentinel reaches the char hook; the docs say "window only". They're #5617's to fix, and this PR picks the fixes up when #5617 merges, with nothing to change here. None of them breaks a mod screen: it has no text box of its own, and a mod takes its typing from the char hook, which is still told about every character. The `\b` sentinel only reaches a mod through horizon-ctl's `type`, and the fix turns it back into a Backspace key. Orbital Laser's wheel types its fly speed exactly that way. - **Merge order:** #5616 → #5617 → this. Merged first, this would carry their fragments and stamp them under this PR's merge. - **Conflicts:** #5731 adds a `Game` field and its initialiser at the same two lines of `game.rs` (after `native_shaders`): keep both. After #5617 merges, `git merge origin/main` drops its commits from this diff. Main was merged in on 2026-11-01 (5edb339a7). - **Risk:** low: a new `Screen` variant that no vanilla path opens. **Rollback:** revert before the stamp PR merges; after that, fix forward. ## Self-check **pr_ready** (Rust 1.99.1, `tools/pr_ready.py --quick` on DESKTOP-SNGRNA4-LINUX, against origin/main at bb03a6b2e, 2 min 14 s) | Check | Result | | --- | --- | | Scope | ⚠️ 10 files, +564 −57; 621 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (29 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (43 s) | | tests: horizon-client | ✅ 1677 passed (54 s) | | doc tests | ✅ 0 passed (2 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#6468
No description provided.