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
Options.hideGui.
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 GUI, status bars, experience bar, mob effects overlays, and boss bar and before the sleep overlay |
Before DEMO_TIMER |
Render after sleep overlay and before the demo timer, debug overlay, scoreboard, overlay message (action bar), and title and subtitle |
Before CHAT |
Render after the debug overlay, scoreboard, overlay message (action bar), and title and subtitle and before chat hud, player list, and sound subtitles |
After SUBTITLES |
Render after everything |
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic voidaddFirst(net.minecraft.resources.Identifier id, HudElement element) Adds an element to the front.static voidaddLast(net.minecraft.resources.Identifier id, HudElement element) Adds an element to the end.static voidattachElementAfter(net.minecraft.resources.Identifier afterThis, net.minecraft.resources.Identifier identifier, HudElement element) Attaches an element after the element with the specified identifier.static voidattachElementBefore(net.minecraft.resources.Identifier beforeThis, net.minecraft.resources.Identifier identifier, HudElement element) Attaches an element before the element with the specified identifier.static voidremoveElement(net.minecraft.resources.Identifier identifier) Removes an element with the specified identifier.static voidreplaceElement(net.minecraft.resources.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
static void attachElementBefore(net.minecraft.resources.Identifier beforeThis, net.minecraft.resources.Identifier identifier, HudElement element) 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
static void attachElementAfter(net.minecraft.resources.Identifier afterThis, net.minecraft.resources.Identifier identifier, HudElement element) 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
static void removeElement(net.minecraft.resources.Identifier identifier) Removes an element with the specified identifier.- Parameters:
identifier- the identifier of the element to remove
-
replaceElement
static void replaceElement(net.minecraft.resources.Identifier identifier, Function<HudElement, HudElement> replacer) 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.
If the replaced element is a status bar (like
HEALTH_BAR,ARMOR_BARorFOOD_BAR), it may be necessary to register a newStatusBarHeightProviderinHudStatusBarHeightRegistry.- Parameters:
identifier- the identifier of the element to replacereplacer- a function that takes the old element and returns the new element
-