zh_cn:tutorial:tools
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| zh_cn:tutorial:tools [2021/07/25 01:29] – created solidblock | zh_cn:tutorial:tools [2024/08/23 13:26] (current) – [添加工具] solidblock | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== 添加工具 ====== | ====== 添加工具 ====== | ||
| + | :!: 本教程自 1.20.5 之后可能已经过时,因为使用了物品组件。最新教程可见 Fabric Docs 上的对应页面。 | ||
| ==== 创建工具材料 ==== | ==== 创建工具材料 ==== | ||
| Line 78: | Line 78: | ||
| </ | </ | ||
| - | '' | + | '' |
| <code java [enable_line_numbers=true]> | <code java [enable_line_numbers=true]> | ||
| public class PotatoToolMaterial implements ToolMaterial { | public class PotatoToolMaterial implements ToolMaterial { | ||
| Line 88: | Line 88: | ||
| </ | </ | ||
| - | '' | + | '' |
| ==== 创建工具 ==== | ==== 创建工具 ==== | ||
| Line 95: | Line 95: | ||
| <code java [enable_line_numbers=true]> | <code java [enable_line_numbers=true]> | ||
| - | public static ToolItem POTATO_SHOVEL = new ShovelItem(PotatoToolMaterial.INSTANCE, | + | public static ToolItem POTATO_SHOVEL = new ShovelItem(PotatoToolMaterial.INSTANCE, |
| - | public static ToolItem POTATO_SWORD = new SwordItem(PotatoToolMaterial.INSTANCE, | + | public static ToolItem POTATO_SWORD = new SwordItem(PotatoToolMaterial.INSTANCE, |
| </ | </ | ||
| Line 110: | Line 110: | ||
| 使用自定义的子类: | 使用自定义的子类: | ||
| <code java> | <code java> | ||
| - | public static ToolItem POTATO_PICKAXE = new CustomPickaxeItem(PotatoToolMaterial.INSTANCE, | + | public static ToolItem POTATO_PICKAXE = new CustomPickaxeItem(PotatoToolMaterial.INSTANCE, |
| - | public static ToolItem POTATO_AXE = new CustomAxeItem(PotatoToolMaterial.INSTANCE, | + | public static ToolItem POTATO_AXE = new CustomAxeItem(PotatoToolMaterial.INSTANCE, |
| - | public static ToolItem POTATO_HOE = new CustomHoeItem(PotatoToolMaterial.INSTANCE, | + | public static ToolItem POTATO_HOE = new CustomHoeItem(PotatoToolMaterial.INSTANCE, |
| </ | </ | ||
| - | If you want to add any special attributes or behaviors to your tool, create a subclass that extends one of the base tool classes, and override any required methods. | + | 如果要向工具添加任何特殊属性或行为,请创建一个子类来扩展基本工具类,并重写任何需要的的方法。 |
| ==== 注册物品 ==== | ==== 注册物品 ==== | ||
zh_cn/tutorial/tools.1627176560.txt.gz · Last modified: 2021/07/25 01:29 by solidblock