Interface HudElementRegistry
Operations relative to a vanilla element will inherit that element's render condition.
The render condition for all vanilla layers except VanillaHudElements.SLEEP
is GameOptions.hudHidden
.
Only addFirst(Identifier, HudElement)
and addLast(Identifier, HudElement)
will not inherit any render condition.
There is currently no mechanism to change the render condition of a vanilla element.
For vanilla layers, see VanillaHudElements
.
Common places to add layers (as of 1.21.6):
Injection Point | Use Case |
---|---|
Before MISC_OVERLAYS |
Render before everything |
After MISC_OVERLAYS |
Render after misc overlays (vignette, spyglass, and powder snow) and before the crosshair |
After BOSS_BAR |
Render after most main hud layers like hotbar, spectator hud, status bars, experience bar, status effects overlays, and boss bar and before the sleep overlay |
Before DEMO_TIMER |
Render after sleep overlay and before the demo timer, debug HUD, scoreboard, overlay message (action bar), and title and subtitle |
Before CHAT |
Render after the debug HUD, scoreboard, overlay message (action bar), and title and subtitle and before ChatHud , player list, and sound subtitles |
After SUBTITLES |
Render after everything |
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic void
addFirst
(Identifier id, HudElement element) Adds an element to the front.static void
addLast
(Identifier id, HudElement element) Adds an element to the end.static void
attachElementAfter
(Identifier afterThis, Identifier identifier, HudElement element) Attaches an element after the element with the specified identifier.static void
attachElementBefore
(Identifier beforeThis, Identifier identifier, HudElement element) Attaches an element before the element with the specified identifier.static void
removeElement
(Identifier identifier) Removes an element with the specified identifier.static void
replaceElement
(Identifier identifier, Function<HudElement, HudElement> replacer) Replaces an element with the specified identifier, the element retains its original identifier.
-
Method Details
-
addFirst
Adds an element to the front.- Parameters:
element
- the element to add
-
addLast
Adds an element to the end.- Parameters:
element
- the element to add
-
attachElementBefore
Attaches an element before the element with the specified identifier.The render condition of the vanilla element being attached to, if any, also applies to the new element.
- Parameters:
beforeThis
- the identifier of the element to add the new element beforeidentifier
- the identifier of the new elementelement
- the element to add
-
attachElementAfter
Attaches an element after the element with the specified identifier.The render condition of the vanilla element being attached to, if any, also applies to the new element.
- Parameters:
afterThis
- the identifier of the element to add the new element afteridentifier
- the identifier of the new elementelement
- the element to add
-
removeElement
Removes an element with the specified identifier.- Parameters:
identifier
- the identifier of the element to remove
-
replaceElement
Replaces an element with the specified identifier, the element retains its original identifier.The render condition of the vanilla element being replaced, if any, also applies to the new element.
- Parameters:
identifier
- the identifier of the element to replacereplacer
- a function that takes the old element and returns the new element
-