Interface ItemTooltipDataCallback
public interface ItemTooltipDataCallback
Event for adding more tooltip data to a stack's tooltip.
Called when an item stack's tooltip is rendered.
Keep in mind that:
- This event should be used for adding item independent data.
If your data only affects one item, or one class, you should override
Item.getTooltipImage(net.minecraft.world.item.ItemStack)instead of using this event. - If
Item.getTooltipImage(net.minecraft.world.item.ItemStack)is not empty for the stack, it's added to the list before the event is fired. - Data added to
listwill be converted to aTooltipComponentviaTooltipComponentCallback.EVENTbefore being rendered. If you don't register a TooltipComponent for your data, minecraft will throw an error. - These are rendered between item's name and the rest of the tooltip and
all data added to
listwill be rendered in the order they were added, so the first added is rendered on top while the last added is at the bottom.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.fabricmc.fabric.api.event.Event<ItemTooltipDataCallback>Fired whenItemStack.getTooltipImage()is called. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetTooltipData(net.minecraft.world.item.ItemStack stack, List<net.minecraft.world.inventory.tooltip.TooltipComponent> list) Called when an item stack's tooltip is rendered.
-
Field Details
-
EVENT
Fired whenItemStack.getTooltipImage()is called.
-
-
Method Details
-
getTooltipData
void getTooltipData(net.minecraft.world.item.ItemStack stack, List<net.minecraft.world.inventory.tooltip.TooltipComponent> list) Called when an item stack's tooltip is rendered. Any data added tolistwill be rendered with the tooltip.- Parameters:
stack- the stack requesting tooltip data.list- the list containing the data's to be displayed on the stack's tooltip.
-