[GH-ISSUE #6243] Native mods: HUD layers around vanilla's, RegisterGuiLayersEvent and RenderGuiLayerEvent #2030

Closed
opened 2026-11-02 15:51:29 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @levzzz5154 on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6243

Originally assigned to: @levzzz5154 on GitHub.

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

Part of #4953 ("HUD layers placed between vanilla's own (RegisterGuiLayersEvent); a mod already draws its own HUD boxes (hud) and health rows (health_hud)").

native_hud lets a mod draw boxes at the corners and native_health_hud replaces the health rows, but a mod cannot draw at a place in vanilla's HUD order (over the hotbar but under the chat, say) or hide one vanilla layer. NeoForge's answer is RegisterGuiLayersEvent (registerAbove(vanilla layer, id, layer), registerBelow, registerAboveAll, registerBelowAll) for placing a layer, and RenderGuiLayerEvent.Pre (cancel hides the layer) and .Post around each vanilla layer.

Vanilla 26.3 draws the HUD in Hud.extractRenderState; NeoForge turns each step into a named layer (ids such as minecraft:crosshair, hotbar, player_health, contextual_info_bar, effects, boss_overlay, sleep_overlay, scoreboard_sidebar, overlay_message, title, chat, tab_list, subtitle_overlay) and posts the events as each layer renders; a layer the HUD toggle (F1) hides posts nothing.

Horizon's hud_layers (game.rs) paints in its own order, one batch, so both "above X" and "below X" are just "draw after/before X's paint". Proposal, the smallest API that gives both: two hooks around each vanilla layer Horizon draws,

  • native_gui_layer_pre(layer, batch, canceled): draw "below layer" here; set canceled to hide the layer.
  • native_gui_layer_post(layer, batch): draw "above layer" here.

A mod keeps its own list of what it draws where, which is all RegisterGuiLayersEvent adds on top of the two events; registerAboveAll is chat's or tab_list's post, registerBelowAll is crosshair's pre. Layers fire in Horizon's paint order, which keeps vanilla's order for everything that overlaps; the health, armor, food and air rows are one pass in Horizon (player_health), and the camera overlays (vignette, pumpkin, powder snow, portal, nausea) are drawn by the screen-effects pass, not the HUD batch, so they are left out. Client only. API from a fragment.

Originally created by @levzzz5154 on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6243 Originally assigned to: @levzzz5154 on GitHub. > 🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #4953 ("HUD layers placed between vanilla's own (`RegisterGuiLayersEvent`); a mod already draws its own HUD boxes (`hud`) and health rows (`health_hud`)"). `native_hud` lets a mod draw boxes at the corners and `native_health_hud` replaces the health rows, but a mod cannot draw at a place in vanilla's HUD order (over the hotbar but under the chat, say) or hide one vanilla layer. NeoForge's answer is `RegisterGuiLayersEvent` (`registerAbove(vanilla layer, id, layer)`, `registerBelow`, `registerAboveAll`, `registerBelowAll`) for placing a layer, and `RenderGuiLayerEvent.Pre` (cancel hides the layer) and `.Post` around each vanilla layer. Vanilla 26.3 draws the HUD in `Hud.extractRenderState`; NeoForge turns each step into a named layer (ids such as `minecraft:crosshair`, `hotbar`, `player_health`, `contextual_info_bar`, `effects`, `boss_overlay`, `sleep_overlay`, `scoreboard_sidebar`, `overlay_message`, `title`, `chat`, `tab_list`, `subtitle_overlay`) and posts the events as each layer renders; a layer the HUD toggle (F1) hides posts nothing. Horizon's `hud_layers` (game.rs) paints in its own order, one batch, so both "above X" and "below X" are just "draw after/before X's paint". Proposal, the smallest API that gives both: two hooks around each vanilla layer Horizon draws, - `native_gui_layer_pre(layer, batch, canceled)`: draw "below layer" here; set `canceled` to hide the layer. - `native_gui_layer_post(layer, batch)`: draw "above layer" here. A mod keeps its own list of what it draws where, which is all `RegisterGuiLayersEvent` adds on top of the two events; `registerAboveAll` is `chat`'s or `tab_list`'s post, `registerBelowAll` is `crosshair`'s pre. Layers fire in Horizon's paint order, which keeps vanilla's order for everything that overlaps; the health, armor, food and air rows are one pass in Horizon (`player_health`), and the camera overlays (vignette, pumpkin, powder snow, portal, nausea) are drawn by the screen-effects pass, not the HUD batch, so they are left out. Client only. API from a fragment.
Author
Owner

@levzzz5154 commented on GitHub (Nov 1, 2026):

/claim

<!-- gh-comment-id:6562015491 --> @levzzz5154 commented on GitHub (Nov 1, 2026): /claim
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#2030
No description provided.