tutorial:tools
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:tools [2023/09/07 05:32] – [Creating Tools] drakonkinst | tutorial:tools [2024/08/23 13:25] (current) – [Adding Tools] solidblock | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Adding Tools ====== | ====== Adding Tools ====== | ||
| + | :!: This tutorial may be **outdated** as since 1.20.5, item components are used. For latest tutorial see [[https:// | ||
| - | ==== Creating a Tool Material ==== | + | ===== Creating a Tool Material |
| Tools require a ''< | Tools require a ''< | ||
| Line 17: | Line 18: | ||
| < | < | ||
| public class PotatoToolMaterial implements class_1832 { | public class PotatoToolMaterial implements class_1832 { | ||
| - | | ||
| [...] | [...] | ||
| } | } | ||
| Line 27: | Line 27: | ||
| ''< | ''< | ||
| < | < | ||
| - | @Override | + | |
| - | public int method_8025() { | + | public int method_8025() { |
| - | return 500; | + | return 500; |
| - | } | + | } |
| </ | </ | ||
| Line 36: | Line 36: | ||
| ''< | ''< | ||
| < | < | ||
| - | @Override | + | |
| - | public float method_8027() { | + | public float method_8027() { |
| - | return 5.0F; | + | return 5.0F; |
| - | } | + | } |
| </ | </ | ||
| Line 45: | Line 45: | ||
| ''< | ''< | ||
| < | < | ||
| - | @Override | + | |
| - | public float method_8028() { | + | public float method_8028() { |
| - | return 3.0F; | + | return 3.0F; |
| - | } | + | } |
| </ | </ | ||
| Line 54: | Line 54: | ||
| ''< | ''< | ||
| < | < | ||
| - | @Override | + | |
| - | public int method_8024() { | + | public int method_8024() { |
| - | return 2; | + | return 2; |
| - | } | + | } |
| </ | </ | ||
| Line 63: | Line 63: | ||
| ''< | ''< | ||
| < | < | ||
| - | @Override | + | |
| - | public int method_8026() { | + | public int method_8026() { |
| - | return 15; | + | return 15; |
| - | } | + | } |
| </ | </ | ||
| Line 72: | Line 72: | ||
| ''< | ''< | ||
| < | < | ||
| - | @Override | + | |
| - | public class_1856 method_8023() { | + | public class_1856 method_8023() { |
| - | return class_1856.method_8091(class_1802.field_8567); | + | return class_1856.method_8091(class_1802.field_8567); |
| - | } | + | } |
| </ | </ | ||
| - | ''< | + | ''< |
| < | < | ||
| public class PotatoToolMaterial implements class_1832 { | public class PotatoToolMaterial implements class_1832 { | ||
| - | |||
| public static final PotatoToolMaterial INSTANCE = new PotatoToolMaterial(); | public static final PotatoToolMaterial INSTANCE = new PotatoToolMaterial(); | ||
| | | ||
| Line 90: | Line 89: | ||
| '' | '' | ||
| - | ==== Creating Tools ==== | + | ===== Creating Tools Items ===== |
| - | **In newer versions, all base tool class constructors are public and can be used directly to register the item.** This constructor lets you specify attack damage and attack speed of the tool. | + | **In newer versions, all base tool class constructors are public and can be used directly to register the item.** This constructor lets you specify attack damage and attack speed of the tool. Remember they should be registered (see [[items]] tutorial). |
| < | < | ||
| - | public static class_1831 POTATO_PICKAXE = new PickaxeItem(PotatoToolMaterial.INSTANCE, | + | public final class TutorialItems { |
| - | public static class_1831 POTATO_AXE = new AxeItem(PotatoToolMaterial.INSTANCE, | + | |
| - | public static class_1831 POTATO_HOE = new HoeItem(PotatoToolMaterial.INSTANCE, | + | public static class_1831 POTATO_AXE = new AxeItem(PotatoToolMaterial.INSTANCE, |
| + | public static class_1831 POTATO_HOE = new HoeItem(PotatoToolMaterial.INSTANCE, | ||
| + | } | ||
| </ | </ | ||
| - | === Creating Tool Subclasses === | + | ===== Creating Tool Subclasses |
| **This section is not necessary in the current version of Fabric.** This is a good way to implement special attributes or behaviors for your tool, however. | **This section is not necessary in the current version of Fabric.** This is a good way to implement special attributes or behaviors for your tool, however. | ||
| Line 117: | Line 118: | ||
| Using the public classes: | Using the public classes: | ||
| < | < | ||
| - | public static class_1831 POTATO_PICKAXE = new CustomPickaxeItem(PotatoToolMaterial.INSTANCE, | + | |
| - | public static class_1831 POTATO_AXE = new CustomAxeItem(PotatoToolMaterial.INSTANCE, | + | public static class_1831 POTATO_AXE = new CustomAxeItem(PotatoToolMaterial.INSTANCE, |
| - | public static class_1831 POTATO_HOE = new CustomHoeItem(PotatoToolMaterial.INSTANCE, | + | public static class_1831 POTATO_HOE = new CustomHoeItem(PotatoToolMaterial.INSTANCE, |
| </ | </ | ||
| - | ==== Registering Tools ==== | + | ===== Making your tool work with non-vanilla blocks |
| - | + | ||
| - | For a recap on registering items, read through the item tutorial [[tutorial: | + | |
| - | + | ||
| - | ==== Making your tool work with non-vanilla blocks ==== | + | |
| - | Visit the last section of https:// | + | See [[mining_levels]]. |
tutorial/tools.1694064738.txt.gz · Last modified: 2023/09/07 05:32 by drakonkinst