Package net.minecraftforge.client.event
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
TooltipComponent
s 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.-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ItemStack
private int
private final int
private final int
private final List<com.mojang.datafixers.util.Either<FormattedText,
TooltipComponent>> -
Constructor Summary
ConstructorDescriptionGatherComponents
(ItemStack itemStack, int screenWidth, int screenHeight, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> tooltipElements, int maxWidth) -
Method Summary
Modifier and TypeMethodDescriptionint
int
int
List<com.mojang.datafixers.util.Either<FormattedText,
TooltipComponent>> The elements to be rendered.void
setMaxWidth
(int maxWidth) Set the maximum width for the text components of the tooltip (or -1 for no maximum width)Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getParentListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult, setup
-
Field Details
-
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
-
GatherComponents
public GatherComponents(ItemStack itemStack, int screenWidth, int screenHeight, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> tooltipElements, int maxWidth)
-
-
Method Details
-
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
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)
-