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
Fired when a tooltip gathers the
TooltipComponent
s to be rendered, before any text wrapping or processing.
The list of components and the maximum width of the tooltip can be modified through this event.
This event is cancellable, and does not have a result.
If this event is cancelled, then the list of components will be empty, causing the tooltip to not be rendered and
the corresponding RenderTooltipEvent.Pre
and RenderTooltipEvent.Color
to not be fired.
This event is fired on the main Forge event bus, only on the logical client.
-
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 TypeMethodDescriptionReturns 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 maximum width of the tooltip when being rendered.int
Returns the height of the screen.int
Returns the width of the screen.List<com.mojang.datafixers.util.Either<FormattedText,
TooltipComponent>> Returns the modifiable list of elements to be rendered on the tooltip.void
setMaxWidth
(int maxWidth) Sets the maximum width of the tooltip.Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
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
@Internal public GatherComponents(ItemStack itemStack, int screenWidth, int screenHeight, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> tooltipElements, int maxWidth)
-
-
Method Details
-
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
-
getScreenWidth
public int getScreenWidth()Returns the width of the screen.. The lines of text within the tooltip are wrapped to be within the screen width, and the tooltip box itself is moved to be within the screen width.- Returns:
- the width of the screen
-
getScreenHeight
public int getScreenHeight()Returns the height of the screen. The tooltip box is moved to be within the screen height.- Returns:
- the height of the screen
-
getTooltipElements
Returns the modifiable list of elements to be rendered on the tooltip. These elements can be either formatted text or custom tooltip components.- Returns:
- the modifiable list of elements to be rendered on the tooltip
-
getMaxWidth
public int getMaxWidth()Returns the maximum width of the tooltip when being rendered.A value of
-1
means an unlimited maximum width. However, an unlimited maximum width will still be wrapped to be within the screen bounds.- Returns:
- the maximum width of the tooltip when being rendered
-
setMaxWidth
public void setMaxWidth(int maxWidth) Sets the maximum width of the tooltip. Use-1
for unlimited maximum width.- Parameters:
maxWidth
- the new maximum width
-