tutorial:tooltip
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:tooltip [2024/08/23 13:10] – solidblock | tutorial:tooltip [2025/07/09 01:55] (current) – typo fix cassiancc | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ~~REDIRECT> | ||
| - | |||
| ====== Adding a tooltip ====== | ====== Adding a tooltip ====== | ||
| ===== Item tooltip ===== | ===== Item tooltip ===== | ||
| Line 47: | Line 45: | ||
| } | } | ||
| </ | </ | ||
| + | > :!: The method is deprecated since 1.21.5. To add item tooltips for 1.21.5, please use Fabric API. | ||
| ===== Block tooltip ===== | ===== Block tooltip ===== | ||
| Line 67: | Line 66: | ||
| </ | </ | ||
| - | For versions since 1.20.5: | + | For versions since 1.20.5, before 1.21.5: |
| < | < | ||
| public class CustomBlock extends Block { | public class CustomBlock extends Block { | ||
| Line 78: | Line 77: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ===== Adding tooltips in 1.21.5 ===== | ||
| + | |||
| + | Since 1.21.5, the implementation of item tooltips are rewritten. Most item tooltips are implemented with item components now, which may be influenced by '' | ||
| + | <code java> | ||
| + | ItemTooltipCallback.EVENT.register((itemStack, | ||
| + | if (!itemStack.isOf(TutorialItems.CUSTOM_ITEM)) { | ||
| + | return; | ||
| + | } | ||
| + | list.add(Text.translatable(" | ||
| + | }); | ||
| + | </ | ||
| + | |||
| + | The example adds a custom tooltip for the item we created in the [[items]] tutorial. | ||
tutorial/tooltip.1724418608.txt.gz · Last modified: 2024/08/23 13:10 by solidblock