Class RenderNameTagEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.client.event.RenderNameTagEvent

public class RenderNameTagEvent extends EntityEvent
This event is fired before an entity renderer renders the nameplate of an entity. It allows reacting to the render and controlling if the name plate will be rendered, as well as changing the rendered name.

This event is only fired on the logical client.

See Also:
  • Field Details

    • originalContent

      private final Component originalContent
    • entityRenderer

      private final EntityRenderer<?> entityRenderer
    • poseStack

      private final PoseStack poseStack
    • multiBufferSource

      private final MultiBufferSource multiBufferSource
    • packedLight

      private final int packedLight
    • partialTick

      private final float partialTick
    • content

      private Component content
    • canRender

      private TriState canRender
  • Constructor Details

  • Method Details

    • setCanRender

      public void setCanRender(TriState canRender)
      Changes if the content of the nameplate will be rendered. TriState.TRUE and TriState.FALSE will allow/deny the render respectively.

      Using TriState.DEFAULT will cause the name to render if EntityRenderer.shouldShowName(T) returns true.

    • canRender

      public TriState canRender()
      Returns if the nameplate will render or not.
      Returns:
      if the nameplate will render or not
    • setContent

      public void setContent(Component contents)
      Sets the new text on the nameplate.
      Parameters:
      contents - the new text
    • getContent

      public Component getContent()
      Returns the text on the nameplate that will be rendered.
      Returns:
      the text on the nameplate that will be rendered
    • getOriginalContent

      public Component getOriginalContent()
      Returns the original text on the nameplate.
      Returns:
      the original text on the nameplate
    • getEntityRenderer

      public EntityRenderer<?> getEntityRenderer()
      Returns the entity renderer rendering the nameplate.
      Returns:
      the entity renderer rendering the nameplate
    • getPoseStack

      public PoseStack getPoseStack()
      Returns the pose stack used for rendering.
      Returns:
      the pose stack used for rendering
    • getMultiBufferSource

      public MultiBufferSource getMultiBufferSource()
      Returns the source of rendering buffers.
      Returns:
      the source of rendering buffers
    • getPackedLight

      public int getPackedLight()
      Returns the amount of packed (sky and block) light for rendering.
      Returns:
      the amount of packed (sky and block) light for rendering
      See Also:
    • getPartialTick

      public float getPartialTick()
      Returns the partial tick.
      Returns:
      the partial tick