Class RenderTooltipEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.RenderTooltipEvent
Direct Known Subclasses:
RenderTooltipEvent.Pre, RenderTooltipEvent.Texture

public abstract class RenderTooltipEvent extends net.neoforged.bus.api.Event
Fired during tooltip rendering. See the various subclasses for listening to specific events.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Fired when a tooltip gathers the TooltipComponents to be rendered, before any text wrapping or processing.
    static class 
    Fired before the tooltip is rendered.
    static class 
    Fired when the textures for the tooltip background are determined.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final List<net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent>
     
    protected net.minecraft.client.gui.Font
     
    protected final net.minecraft.client.gui.GuiGraphics
     
    protected final net.minecraft.world.item.ItemStack
     
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    RenderTooltipEvent(net.minecraft.world.item.ItemStack itemStack, net.minecraft.client.gui.GuiGraphics graphics, int x, int y, net.minecraft.client.gui.Font font, List<net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent> components)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent>
    Returns the unmodifiable list of tooltip components.
    net.minecraft.client.gui.Font
    Returns The font used to render the text.
    net.minecraft.client.gui.GuiGraphics
    Returns the graphics helper for the gui.
    net.minecraft.world.item.ItemStack
    Returns the item stack which the tooltip is being rendered for, or an empty item stack if there is no associated item stack.
    int
    Returns the X position of the tooltip box.
    int
    Returns the Y position of the tooltip box.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • itemStack

      protected final net.minecraft.world.item.ItemStack itemStack
    • graphics

      protected final net.minecraft.client.gui.GuiGraphics graphics
    • x

      protected int x
    • y

      protected int y
    • font

      protected net.minecraft.client.gui.Font font
    • components

      protected final List<net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent> components
  • Constructor Details

    • RenderTooltipEvent

      @Internal protected RenderTooltipEvent(net.minecraft.world.item.ItemStack itemStack, net.minecraft.client.gui.GuiGraphics graphics, int x, int y, net.minecraft.client.gui.Font font, List<net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent> components)
  • Method Details

    • getItemStack

      public net.minecraft.world.item.ItemStack getItemStack()
      Returns the item stack which the tooltip is being rendered for, or an empty item stack if there is no associated item stack.
      Returns:
      the item stack which the tooltip is being rendered for, or an empty item stack if there is no associated item stack
    • getGraphics

      public net.minecraft.client.gui.GuiGraphics getGraphics()
      Returns the graphics helper for the gui.
      Returns:
      the graphics helper for the gui
    • getComponents

      public List<net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent> getComponents()
      Returns the unmodifiable list of tooltip components.

      Use ItemTooltipEvent or RenderTooltipEvent.GatherComponents to modify tooltip contents or components.

      Returns:
      the unmodifiable list of tooltip components
    • getX

      public int getX()
      Returns the X position of the tooltip box. By default, this is the mouse X position.
      Returns:
      the X position of the tooltip box
    • getY

      public int getY()
      Returns the Y position of the tooltip box. By default, this is the mouse Y position.
      Returns:
      the Y position of the tooltip box
    • getFont

      public net.minecraft.client.gui.Font getFont()
      Returns The font used to render the text.
      Returns:
      The font used to render the text