tutorial:tooltip
This is an old revision of the document!
Adding a tooltip
In your item class, override appendTooltip
like so (see lang for how to translate the tooltip) :
@Override public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) { // default white text tooltip.add( new TranslatableTextContent("item.tutorial.fabric_item.tooltip") ); // formatted red text tooltip.add( new TranslatableTextContent("item.tutorial.fabric_item.tooltip").formatted(Formatting.RED) ); }You can also append your tooltip in the block class by overriding a similar method :
@Override @Override public void appendTooltip(ItemStack itemStack, BlockView world, List<Text> tooltip, TooltipContext tooltipContext) { tooltip.add( new TranslatableTextContent("block.tutorial.fabric_block.tooltip") ); }
tutorial/tooltip.1649837278.txt.gz · Last modified: 2022/04/13 08:07 by daomephsta