[PR #3345] [MERGED] Native mods: stable hook points (game/native_hooks.rs) #4917

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3345
Author: @ludovic111
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: feat/native-hook-points


📝 Commits (1)

  • 360272f Native mods: stable hook points (game/native_hooks.rs)

📊 Changes

7 files changed (+366 additions, -21 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+4 -0)
📝 crates/horizon-client/src/game/chat.rs (+3 -3)
📝 crates/horizon-client/src/game/commands.rs (+1 -1)
📝 crates/horizon-client/src/game/control.rs (+2 -0)
📝 crates/horizon-client/src/game/extras.rs (+29 -17)
➕ crates/horizon-client/src/game/native_hooks.rs (+326 -0)
📝 crates/horizon-client/src/game/remote.rs (+1 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Horizon's code mods are moving to native mods (horizon-mixins bundles, docs/native-mods.md). The official ones (Zoom, FPS Counter, Keystrokes, Minimap) each live in a native/<name>/ folder of horizon-rust/horizon-mods. This PR gives them stable hook points: game/native_hooks.rs, a set of empty functions the game calls at fixed places, for bundles to hook with HEAD. A mod that hooks only these keeps building on newer Horizons.

  • Hooks: native_frame, native_tick, native_hud, native_key, native_wheel (claimed), native_command (ran), native_zoom, native_minimap. Hooks that answer take an out parameter, so several mods can hook the same point.
  • Helpers for bundles:
    • drawing as the HUD extras do (native_fill, native_text, native_text_width, native_corner_shown);
    • frame rate and clicks per second;
    • key mappings;
    • chat;
    • settings kept where the WebAssembly mod of the same id kept them: horizon-mods/.horizon-mod-data/<id>/<key> files, and key.<id>.<name> lines in horizon-mods.txt.
  • Call sites:
    • game.rs and remote.rs call the tick, key and wheel hooks; chat, commands and control call the command hook.
    • extras.rs: zoom and minimap ask the native hook first, then a WebAssembly mod's.
    • FPS and clicks are recorded whenever a mod might read them.
    • draw_extras calls native_hud last.
  • NATIVE_HOOKS_API = 1: hook points are only ever added, and each addition raises it. The launcher (#3323) builds a mod that names hooks: 1 on any Horizon whose API is at least 1.
  • Test hook_points_stay_hookable: no cfg and no macro in the file's bodies (horizon-mixins refuses a target with either), and the API line keeps its form (the launcher reads it).

With no native mod, every hook is an empty call: players see no change. The settings page for native mods is the stacked PR.

Proof:

  • Each of the four mods' CI applies its mod with horizon-mixins 0500ff2 on this stack and builds the game.
  • An offscreen game driven with horizon-ctl, on fresh temporary data:
    • Zoom reads a player's WebAssembly settings (8x, key C): C zooms 8x, and the wheel zooms instead of moving the hotbar.
    • FPS Counter, Keystrokes and Minimap draw in their stored corner and move when the setting changes.
    • All four applied together (18 injections, one build) play at once.

The pr_ready block below covers this PR and the stacked settings page together (1a + 1b). The module doc's wording changed after it ran; that was a doc-only change.

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at 07e4a8665, 29 min 45 s)

Check Result
Scope ⚠️ 12 files, +556 −30; 586 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 401 passed (1 min 14 s)
rustfmt ✅ (6 s)
clippy ✅ (2 min 1 s)
tests: horizon-client ✅ 1264 passed (4 min 45 s)
doc tests ✅ 0 passed (22 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 ✅ 76 affected, 21 passed (21 min 6 s)
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/3345 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-hook-points` --- ### 📝 Commits (1) - [`360272f`](https://github.com/horizon-rust/horizon/commit/360272fd79d77eb1ca9ef7cae5e3ebcebd2a45a5) Native mods: stable hook points (game/native_hooks.rs) ### 📊 Changes **7 files changed** (+366 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+4 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+3 -3) 📝 `crates/horizon-client/src/game/commands.rs` (+1 -1) 📝 `crates/horizon-client/src/game/control.rs` (+2 -0) 📝 `crates/horizon-client/src/game/extras.rs` (+29 -17) ➕ `crates/horizon-client/src/game/native_hooks.rs` (+326 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Horizon's code mods are moving to native mods (horizon-mixins bundles, docs/native-mods.md). The official ones (Zoom, FPS Counter, Keystrokes, Minimap) each live in a `native/<name>/` folder of horizon-rust/horizon-mods. This PR gives them stable **hook points**: `game/native_hooks.rs`, a set of empty functions the game calls at fixed places, for bundles to hook with HEAD. A mod that hooks only these keeps building on newer Horizons. - **Hooks**: `native_frame`, `native_tick`, `native_hud`, `native_key`, `native_wheel` (`claimed`), `native_command` (`ran`), `native_zoom`, `native_minimap`. Hooks that answer take an out parameter, so several mods can hook the same point. - **Helpers** for bundles: - drawing as the HUD extras do (`native_fill`, `native_text`, `native_text_width`, `native_corner_shown`); - frame rate and clicks per second; - key mappings; - chat; - settings kept where the WebAssembly mod of the same id kept them: `horizon-mods/.horizon-mod-data/<id>/<key>` files, and `key.<id>.<name>` lines in `horizon-mods.txt`. - **Call sites**: - game.rs and remote.rs call the tick, key and wheel hooks; chat, commands and control call the command hook. - extras.rs: zoom and minimap ask the native hook first, then a WebAssembly mod's. - FPS and clicks are recorded whenever a mod might read them. - `draw_extras` calls `native_hud` last. - **`NATIVE_HOOKS_API = 1`**: hook points are only ever added, and each addition raises it. The launcher (#3323) builds a mod that names `hooks: 1` on any Horizon whose API is at least 1. - **Test `hook_points_stay_hookable`**: no `cfg` and no macro in the file's bodies (horizon-mixins refuses a target with either), and the API line keeps its form (the launcher reads it). With no native mod, every hook is an empty call: players see no change. The settings page for native mods is the stacked PR. **Proof**: - Each of the four mods' CI applies its mod with horizon-mixins 0500ff2 on this stack and builds the game. - An offscreen game driven with horizon-ctl, on fresh temporary data: - Zoom reads a player's WebAssembly settings (8x, key C): C zooms 8x, and the wheel zooms instead of moving the hotbar. - FPS Counter, Keystrokes and Minimap draw in their stored corner and move when the setting changes. - All four applied together (18 injections, one build) play at once. The pr_ready block below covers this PR and the stacked settings page together (1a + 1b). The module doc's wording changed after it ran; that was a doc-only change. **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at 07e4a8665, 29 min 45 s) | Check | Result | | --- | --- | | Scope | ⚠️ 12 files, +556 −30; 586 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 401 passed (1 min 14 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (2 min 1 s) | | tests: horizon-client | ✅ 1264 passed (4 min 45 s) | | doc tests | ✅ 0 passed (22 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 | ✅ 76 affected, 21 passed (21 min 6 s) | | 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>
bsakaguchi 2026-11-03 05:08:54 +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#4917
No description provided.