[PR #6290] [MERGED] Native mods: drawing between the HUD's own layers, RegisterGuiLayersEvent #6772

Closed
opened 2026-11-03 06:26:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6290
Author: @levzzz5154
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @levzzz5154

Base: main ← Head: mods/native-gui-layers


📝 Commits (1)

  • caea1cd Native mods: HUD layers around vanilla's (RenderGuiLayerEvent, RegisterGuiLayersEvent)

📊 Changes

5 files changed (+212 additions, -103 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+112 -76)
📝 crates/horizon-client/src/game/mounts.rs (+22 -23)
📝 crates/horizon-client/src/game/native_hooks.rs (+46 -0)
📝 crates/horizon-client/src/game/titles.rs (+12 -4)
➕ tools/native-hook-fragments/gui_layers.json (+20 -0)

📄 Description

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

What and why

Fixes #6243; part of #4953 ("HUD layers placed between vanilla's own"). native_hud draws boxes in the corners and native_health_hud replaces the health rows, but a mod could not draw at a place in vanilla's HUD order or hide one layer. Two hooks, NeoForge's RenderGuiLayerEvent.Pre/.Post (and, with them, RegisterGuiLayersEvent's registerAbove / registerBelow: a mod keeps its own list of what it draws where):

  • native_gui_layer_pre(layer, batch, canceled): draw here to be below the layer; set canceled to hide it.
  • native_gui_layer_post(layer, batch): draw here to be above the layer (also after a layer a mod hid).

Layer ids, in Horizon's paint order: minecraft:crosshair, hotbar, effects, boss_overlay, vehicle_health (only riding a mount), contextual_info_bar, player_health, selected_item_name, sleep_overlay, overlay_message, title, scoreboard_sidebar, subtitle_overlay, chat, tab_list. A layer F1 hides fires nothing (as in vanilla); the chat screen draws the focused chat itself, so chat is the unfocused lines.

Where Horizon differs from NeoForge's layer list, and how: the health, armor, food and air rows are one pass in HealthHud::layout (they share a random sequence), so they are one layer, player_health. The mount's jump bar, the locator bar (with its background) and the experience bar with its level number are NeoForge's contextual-bar layers; here they are the one contextual_info_bar layer (vanilla shows only one of them at a time). The camera overlays (vignette, pumpkin, powder snow, portal, nausea) are drawn by the screen-effects pass, not the HUD batch, and the debug screen comes after the screens, so neither is a layer. The spectator tooltip and the demo overlay are not drawn by Horizon's HUD pass.

To make the layers contiguous, hud_layers was reordered a little: the locator bar and the experience bar draw together before the health rows (they do not overlap), draw_mount_hud no longer draws the jump bar (draw_jump_bar), and draw_titles is split into draw_overlay_message and draw_title. A hidden layer still runs its logic (the health rows' blink state, the bubble-pop sound, the mount's heart count that raises the bars).

Kind

  • feature: something new for players (a mod places or hides HUD layers)

Vanilla reference

Hud.extractRenderState and its extract* steps in the pinned 26.3 sources; NeoForge's public names for the layer ids and event contracts (RenderGuiLayerEvent, RegisterGuiLayersEvent, VanillaGuiLayers). Horizon keeps its own paint order, which keeps vanilla's wherever layers overlap.

Other projects' code

None; names and contracts only.

Proof in the real game

Offscreen client, single player on the server thread, survival, with a throwaway probe in the two hook bodies (removed before commit; git diff shows no TESTHOOK) that logs each layer's first pre and, from env vars, hides a layer, draws a green box in one layer's pre and a red box in another's post. Screenshots read back with the image reader:

  • The log lists every id above except vehicle_health, which appears once riding a saddled horse (ride @s mount).
  • Hide minecraft:hotbar: the hotbar and its item are gone, the rest of the HUD is unchanged. Hide minecraft:player_health: the hearts, food and air bubbles are gone, the experience bar and level stay.
  • Green box in chat's pre, red box in hotbar's post: the red box is over the hotbar area and under the chat's background (the chat drew after it), the green box sits under the tutorial toast and over the world.
  • Riding a horse with a red box in vehicle_health's post: the mount's hearts draw, the box is over them.

Not run: the locator bar and the jump bar (no waypoints or jumping mount set up), F1, a dedicated server (client hooks), a real native mod bundle, the parity harnesses (--quick). I did not compare pixels of the reordered HUD against a pre-change build; the HUD in the screenshots looks as before.

Self-check

pr_ready (tools/pr_ready.py --quick --base hr/main, against hr/main at 455b6916b)

Check Result
Scope ✅ 5 files, +212 −103
Public tree ✅
Python tests ✅ 586 passed
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 1805 passed
doc tests ✅
Parity ➖ not run (--quick)

🤖 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/6290 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `mods/native-gui-layers` --- ### 📝 Commits (1) - [`caea1cd`](https://github.com/horizon-rust/horizon/commit/caea1cd2924324f67fff31aa0dfcebd5d9204ae9) Native mods: HUD layers around vanilla's (RenderGuiLayerEvent, RegisterGuiLayersEvent) ### 📊 Changes **5 files changed** (+212 additions, -103 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+112 -76) 📝 `crates/horizon-client/src/game/mounts.rs` (+22 -23) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+46 -0) 📝 `crates/horizon-client/src/game/titles.rs` (+12 -4) ➕ `tools/native-hook-fragments/gui_layers.json` (+20 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. ## What and why Fixes #6243; part of #4953 ("HUD layers placed between vanilla's own"). `native_hud` draws boxes in the corners and `native_health_hud` replaces the health rows, but a mod could not draw at a place in vanilla's HUD order or hide one layer. Two hooks, NeoForge's `RenderGuiLayerEvent.Pre`/`.Post` (and, with them, `RegisterGuiLayersEvent`'s registerAbove / registerBelow: a mod keeps its own list of what it draws where): - `native_gui_layer_pre(layer, batch, canceled)`: draw here to be below the layer; set `canceled` to hide it. - `native_gui_layer_post(layer, batch)`: draw here to be above the layer (also after a layer a mod hid). Layer ids, in Horizon's paint order: `minecraft:crosshair`, `hotbar`, `effects`, `boss_overlay`, `vehicle_health` (only riding a mount), `contextual_info_bar`, `player_health`, `selected_item_name`, `sleep_overlay`, `overlay_message`, `title`, `scoreboard_sidebar`, `subtitle_overlay`, `chat`, `tab_list`. A layer F1 hides fires nothing (as in vanilla); the chat screen draws the focused chat itself, so `chat` is the unfocused lines. Where Horizon differs from NeoForge's layer list, and how: the health, armor, food and air rows are one pass in `HealthHud::layout` (they share a random sequence), so they are one layer, `player_health`. The mount's jump bar, the locator bar (with its background) and the experience bar with its level number are NeoForge's contextual-bar layers; here they are the one `contextual_info_bar` layer (vanilla shows only one of them at a time). The camera overlays (vignette, pumpkin, powder snow, portal, nausea) are drawn by the screen-effects pass, not the HUD batch, and the debug screen comes after the screens, so neither is a layer. The spectator tooltip and the demo overlay are not drawn by Horizon's HUD pass. To make the layers contiguous, `hud_layers` was reordered a little: the locator bar and the experience bar draw together before the health rows (they do not overlap), `draw_mount_hud` no longer draws the jump bar (`draw_jump_bar`), and `draw_titles` is split into `draw_overlay_message` and `draw_title`. A hidden layer still runs its logic (the health rows' blink state, the bubble-pop sound, the mount's heart count that raises the bars). ## Kind - [x] feature: something new for players (a mod places or hides HUD layers) ## Vanilla reference `Hud.extractRenderState` and its `extract*` steps in the pinned 26.3 sources; NeoForge's public names for the layer ids and event contracts (`RenderGuiLayerEvent`, `RegisterGuiLayersEvent`, `VanillaGuiLayers`). Horizon keeps its own paint order, which keeps vanilla's wherever layers overlap. ## Other projects' code None; names and contracts only. ## Proof in the real game Offscreen client, single player on the server thread, survival, with a throwaway probe in the two hook bodies (removed before commit; `git diff` shows no TESTHOOK) that logs each layer's first `pre` and, from env vars, hides a layer, draws a green box in one layer's `pre` and a red box in another's `post`. Screenshots read back with the image reader: - The log lists every id above except `vehicle_health`, which appears once riding a saddled horse (`ride @s mount`). - Hide `minecraft:hotbar`: the hotbar and its item are gone, the rest of the HUD is unchanged. Hide `minecraft:player_health`: the hearts, food and air bubbles are gone, the experience bar and level stay. - Green box in `chat`'s `pre`, red box in `hotbar`'s `post`: the red box is over the hotbar area and under the chat's background (the chat drew after it), the green box sits under the tutorial toast and over the world. - Riding a horse with a red box in `vehicle_health`'s `post`: the mount's hearts draw, the box is over them. Not run: the locator bar and the jump bar (no waypoints or jumping mount set up), F1, a dedicated server (client hooks), a real native mod bundle, the parity harnesses (`--quick`). I did not compare pixels of the reordered HUD against a pre-change build; the HUD in the screenshots looks as before. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base hr/main`, against hr/main at 455b6916b) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +212 −103 | | Public tree | ✅ | | Python tests | ✅ 586 passed | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 1805 passed | | doc tests | ✅ | | Parity | ➖ not run (--quick) | 🤖 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:26:24 +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#6772
No description provided.