Client Tooltip Events
dev.architectury.event.events.client.ClientTooltipEvent
Add lines to item tooltips, or hook into how tooltips are rendered and positioned.
Events
| Event | Listener method | Returns |
|---|---|---|
ITEM | append(ItemStack, List<Component> lines, Item.TooltipContext, TooltipFlag) | void - add to the tooltip text. |
RENDER_PRE | renderTooltip(GuiGraphicsExtractor, List<ClientTooltipComponent> texts, int x, int y) | EventResult - interrupt to cancel vanilla tooltip rendering. |
RENDER_MODIFY_POSITION | renderTooltip(GuiGraphicsExtractor, PositionContext) | void - move the tooltip. |
The lines list in ITEM is mutable - add Components to it to append tooltip text. The
PositionContext in RENDER_MODIFY_POSITION exposes getTooltipX/Y() and setTooltipX/Y(int).
Example
Add a line to every diamond's tooltip:
ClientTooltipEvent.ITEM.register((stack, lines, context, flag) -> {
if (stack.is(Items.DIAMOND)) {
lines.add(Component.literal("Shiny!").withStyle(ChatFormatting.AQUA));
}
});