ItemTooltipEvent

Link to itemtooltipevent

This event is fired whenever a tooltip is calculated.

Note: the player may not always be present, make sure you check if it is null before trying to use it

The event is not cancelable.

The event does not have a result.

Importing the class

Link to importing-the-class

Importing the class is recommended for events, simply add this line to the top of your script file.

ZenScript
Copy
import crafttweaker.neoforge.api.event.item.ItemTooltipEvent;

Listening to the event

Link to listening-to-the-event

ZenScript
Copy
events.register<crafttweaker.neoforge.api.event.item.ItemTooltipEvent>(event => {
    println("ItemTooltipEvent ran!");
});

ItemTooltipEvent extends PlayerEvent. That means all methods available in PlayerEvent are also available in ItemTooltipEvent

Name: getFlags

Gets the extra tooltip flags, such as if advanced tooltips should be displayed.

Returns: The tooltip flags
Return Type: TooltipFlag

ZenScript
Copy
// ItemTooltipEvent.getFlags() as TooltipFlag

event.getFlags();

Name: getItemStack

Gets the ItemStack that the tooltip is for.

Returns: The ItemStack that the tooltip is for.
Return Type: IItemStack

ZenScript
Copy
// ItemTooltipEvent.getItemStack() as IItemStack

event.getItemStack();

Name: getPlayer

Gets the player that is viewing the tooltip.

Note: The player can be null

Returns: The player that is viewing the tooltip.
Return Type: Player?

ZenScript
Copy
// ItemTooltipEvent.getPlayer() as Player?

event.getPlayer();

Name: getToolTip

Gets the list of Components that make up the tooltip.

Returns: The list of Component that make up the tooltip.
Return Type: stdlib.List<Component>

ZenScript
Copy
// ItemTooltipEvent.getToolTip() as stdlib.List<Component>

event.getToolTip();
NameTypeHas GetterHas SetterDescription
Name
flags
Type
TooltipFlag
Has Getter
true
Has Setter
false
Description
Gets the extra tooltip flags, such as if advanced tooltips should be displayed.
Name
itemStack
Type
IItemStack
Has Getter
true
Has Setter
false
Description
Gets the ItemStack that the tooltip is for.
Name
player
Type
Player?
Has Getter
true
Has Setter
false
Description
Gets the player that is viewing the tooltip.

Note: The player can be null
Name
tooltip
Type
stdlib.List<Component>
Has Getter
true
Has Setter
false
Description
Gets the list of Components that make up the tooltip.