Class RenderTooltipEvent.GatherComponents

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.client.event.RenderTooltipEvent.GatherComponents
Enclosing class:
RenderTooltipEvent

public static class RenderTooltipEvent.GatherComponents extends net.minecraftforge.eventbus.api.Event
Fires when a tooltip gathers the TooltipComponents to render. This event fires before any text wrapping or text processing. This event allows modifying the components to be rendered as well as specifying a maximum width for the tooltip. The maximum width will cause any text components to be wrapped.
  • Field Details

    • itemStack

      private final ItemStack itemStack
    • screenWidth

      private final int screenWidth
    • screenHeight

      private final int screenHeight
    • tooltipElements

      private final List<com.mojang.datafixers.util.Either<FormattedText,TooltipComponent>> tooltipElements
    • maxWidth

      private int maxWidth
  • Constructor Details

  • Method Details

    • getItemStack

      public ItemStack getItemStack()
      Returns:
      the ItemStack whose tooltip is being rendered or an empty stack if this tooltip is not for a stack
    • getScreenWidth

      public int getScreenWidth()
      Returns:
      the width of the screen
    • getScreenHeight

      public int getScreenHeight()
      Returns:
      the height of the screen
    • getTooltipElements

      public List<com.mojang.datafixers.util.Either<FormattedText,TooltipComponent>> getTooltipElements()
      The elements to be rendered. These can be either formatted text or custom tooltip components. This list is modifiable.
    • getMaxWidth

      public int getMaxWidth()
      Returns:
      the current maximum width for the text components of the tooltip (or -1 for no maximum width)
    • setMaxWidth

      public void setMaxWidth(int maxWidth)
      Set the maximum width for the text components of the tooltip (or -1 for no maximum width)