User Tools

Site Tools


Sidebar

Setup

Basics

Advanced

Items

Blocks and Block Entities

Fluids

Entities

World Generation

Recipe Types

Miscellaneous

Events

Mixins

Dynamic Data Generation

Tutorials for Minecraft 1.15

Tutorials for Minecraft 1.14

Documentation

tutorial:tooltip

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.txt · Last modified: 2021/02/22 00:32 by proudmuslim