zh_cn:tutorial:tooltip
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
zh_cn:tutorial:tooltip [2019/12/18 12:01] – lightcolour | zh_cn:tutorial:tooltip [2024/04/15 01:31] (current) – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== 添加一个物品提示 ====== | ====== 添加一个物品提示 ====== | ||
- | 在您的[[zh_cn: | + | 在您的[[zh_cn: |
- | <code java> | + | |
+ | 对于 1.18.2 及之前的版本: | ||
+ | <yarncode | ||
@Override | @Override | ||
- | public void appendTooltip(ItemStack | + | public void method_7851(class_1799 |
- | tooltip.add(new TranslatableText(" | + | |
+ | // 默认为白色文本 | ||
+ | tooltip.add(new TranslatableText(" | ||
+ | |||
+ | // 格式化为红色文本 | ||
+ | tooltip.add(new TranslatableText(" | ||
} | } | ||
- | </code> | + | </yarncode> |
- | 对于一个方块,执行相同的操作,但在您的[[zh_cn: | + | |
+ | 对于 | ||
+ | < | ||
+ | @Override | ||
+ | public void method_7851(class_1799 itemStack, class_1937 world, List< | ||
+ | tooltip.add(Text.translatable(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 对于 1.20.5 之后的版本: | ||
+ | < | ||
+ | @Override | ||
+ | public void method_7851(class_1799 itemStack, TooltipContext context, List< | ||
+ | tooltip.add(Text.translatable(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 你也可以在[[zh_cn: | ||
+ | < | ||
+ | @Override | ||
+ | public void method_9568(class_1799 itemStack, class_1922 world, List< | ||
+ | // 对于 1.18.2 及之前的版本 | ||
+ | tooltip.add(new TranslatableText("block.tutorial.custom_block.tooltip")); | ||
+ | |||
+ | // 对于 1.19 之后的版本 | ||
+ | tooltip.add(Text.translatable(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 对于 1.20.5 之后的版本: | ||
+ | < | ||
+ | @Override | ||
+ | public void method_9568(class_1799 itemStack, Item.TooltipContext context, List< | ||
+ | tooltip.add(Text.translatable(" | ||
+ | } | ||
+ | </ |
zh_cn/tutorial/tooltip.1576670486.txt.gz · Last modified: 2019/12/18 12:01 by lightcolour