Class RegisterGuiLayersEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.RegisterGuiLayersEvent
All Implemented Interfaces:
IModBusEvent

public class RegisterGuiLayersEvent extends net.neoforged.bus.api.Event implements IModBusEvent
Allows users to register custom layers for GUI rendering.

See also RenderGuiLayerEvent to intercept rendering of registered layers.

This event is not cancellable.

This event is fired on the mod-specific event bus, only on the logical client.

  • Field Details

  • Constructor Details

  • Method Details

    • registerBelowAll

      public void registerBelowAll(ResourceLocation id, GuiLayer layer)
      Registers a layer that renders below all others.
      Parameters:
      id - A unique resource id for this layer
      layer - The layer
    • registerBelow

      public void registerBelow(ResourceLocation other, ResourceLocation id, GuiLayer layer)
      Registers a layer that renders below another.
      Parameters:
      other - The id of the layer to render below. This must be a layer you have already registered or one of the vanilla layers. Do not use other mods' layers.
      id - A unique resource id for this layer
      layer - The layer
    • registerAbove

      public void registerAbove(ResourceLocation other, ResourceLocation id, GuiLayer layer)
      Registers an layer that renders above another.
      Parameters:
      other - The id of the layer to render above. This must be a layer you have already registered or one of the vanilla layers. Do not use other mods' layers.
      id - A unique resource id for this layer
      layer - The layer
    • registerAboveAll

      public void registerAboveAll(ResourceLocation id, GuiLayer layer)
      Registers a layer that renders above all others.
      Parameters:
      id - A unique resource id for this layer
      layer - The layer
    • replaceLayer

      public void replaceLayer(ResourceLocation id, GuiLayer replacement)
      Replace the layer with the given id with a new one.
      Parameters:
      id - the id of the layer to replace
      replacement - the layer to replace it with
      Throws:
      IllegalArgumentException - if a layer with the given id is not yet registered
      See Also:
    • wrapLayer

      public void wrapLayer(ResourceLocation id, UnaryOperator<GuiLayer> wrapper)
      Wrap the layer with the given id in a new layer.

      This can be used, for instance, to apply pose stack transformations to move the layer or resize it.

      Parameters:
      id - the id of the layer to wrap
      wrapper - an unary operator which takes in the old layer and returns the new layer that wraps the old one
      Throws:
      IllegalArgumentException - if a layer with the given id is not yet registered
    • register

      private void register(RegisterGuiLayersEvent.Ordering ordering, @Nullable @Nullable ResourceLocation other, ResourceLocation key, GuiLayer layer)