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 TranslatableText("item.tutorial.fabric_item.tooltip") ); // formatted red text tooltip.add( new TranslatableText("item.tutorial.fabric_item.tooltip").formatted(Formatting.RED) ); }
You can also append your tooltip in the block class by overriding a similar method :
@Override public void appendTooltip(ItemStack itemStack, BlockView world, List<Text> tooltip, TooltipContext tooltipContext) { tooltip.add( new TranslatableText("block.tutorial.fabric_block.tooltip") ); }
tutorial/tooltip.1613953946.txt.gz · Last modified: 2021/02/22 00:32 by proudmuslim