~~REDIRECT>https://docs.fabricmc.net/develop/items/first-item#custom-tooltips~~ ====== Adding a tooltip ====== ===== Item tooltip ===== Sometimes you want to add some extra information when showing the tooltip of the [[items|item]]. To achieve this, you should override your own '''' like so (see [[tutorial:lang]] for how to translate the tooltip). Here we assume you have created your own class (see [[items]]), for example, ''CustomItem'': For versions 1.18.2 and before: public class CustomItem extends Item { // ... @Override public void method_7851(class_1799 itemStack, class_1937 world, List tooltip, class_1836 tooltipContext) { // default white text tooltip.add(new TranslatableText("item.tutorial.custom_item.tooltip")); // formatted red text tooltip.add(new TranslatableText("item.tutorial.custom_item.tooltip").method_27692(class_124.field_1061)); } } For versions since 1.19: public class CustomItem extends Item { // ... @Override public void method_7851(class_1799 itemStack, class_1937 world, List tooltip, class_1836 tooltipContext) { tooltip.add(Text.translatable("item.tutorial.custom_item.tooltip")); } } For versions since 1.20.5: public class CustomItem extends Item { // ... @Override public void method_7851(class_1799 itemStack, TooltipContext context, List tooltip, TooltipType type) { tooltip.add(Text.translatable("item.tutorial.custom_item.tooltip")); } } ===== Block tooltip ===== You can also append your tooltip in the [[blocks|block]] class by overriding a similar method: For versions below 1.20.5: public class CustomBlock extends Block { // ... @Override public void method_9568(class_1799 itemStack, class_1922 world, List tooltip, class_1836 tooltipContext) { // for versions 1.18.2 and before tooltip.add(new TranslatableText("block.tutorial.custom_block.tooltip")); // for versions since 1.19 tooltip.add(Text.translatable("block.tutorial.custom_block.tooltip")); } } For versions since 1.20.5: public class CustomBlock extends Block { // ... @Override public void method_9568(class_1799 itemStack, Item.TooltipContext context, List tooltip, TooltipType options) { tooltip.add(Text.translatable("block.tutorial.custom_block.tooltip")); } }