tutorial:tools
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:tools [2020/09/14 01:50] – fix constructor draylar | tutorial:tools [2022/04/14 08:37] – map2fabricyarn daomephsta | ||
---|---|---|---|
Line 3: | Line 3: | ||
==== Creating a Tool Material ==== | ==== Creating a Tool Material ==== | ||
- | Tools require a '' | + | Tools require a '' |
* durability | * durability | ||
* mining speed | * mining speed | ||
Line 13: | Line 13: | ||
In other words, Tool Materials defines the //base// functionality for tools of that type, and tools can choose to use the values provided by the material, or roll with their own. | In other words, Tool Materials defines the //base// functionality for tools of that type, and tools can choose to use the values provided by the material, or roll with their own. | ||
- | Vanilla Tool Materials can be found in '' | + | Vanilla Tool Materials can be found in '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
- | public class PotatoToolMaterial implements | + | public class PotatoToolMaterial implements |
| | ||
[...] | [...] | ||
} | } | ||
- | </code> | + | </yarncode> |
- | '' | + | '' |
=== Durability === | === Durability === | ||
- | '' | + | '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
@Override | @Override | ||
- | public int getDurability() { | + | public int method_8025() { |
return 500; | return 500; | ||
} | } | ||
- | </code> | + | </yarncode> |
=== Mining Speed === | === Mining Speed === | ||
- | '' | + | '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
@Override | @Override | ||
- | public float getMiningSpeedMultiplier() { | + | public float method_8027() { |
return 5.0F; | return 5.0F; | ||
} | } | ||
- | </code> | + | </yarncode> |
=== Attack Damage === | === Attack Damage === | ||
- | '' | + | '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
@Override | @Override | ||
- | public float getAttackDamage() { | + | public float method_8028() { |
return 3.0F; | return 3.0F; | ||
} | } | ||
- | </code> | + | </yarncode> |
=== Mining Level === | === Mining Level === | ||
- | '' | + | '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
@Override | @Override | ||
- | public int getMiningLevel() { | + | public int method_8024() { |
return 2; | return 2; | ||
} | } | ||
- | </code> | + | </yarncode> |
=== Enchantability === | === Enchantability === | ||
- | '' | + | '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
@Override | @Override | ||
- | public int getEnchantability() { | + | public int method_8026() { |
return 15; | return 15; | ||
} | } | ||
- | </code> | + | </yarncode> |
=== Repair Ingredient === | === Repair Ingredient === | ||
- | '' | + | '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
@Override | @Override | ||
- | public | + | public |
- | return | + | return |
} | } | ||
- | </code> | + | </yarncode> |
- | '' | + | '' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
- | public class PotatoToolMaterial implements | + | public class PotatoToolMaterial implements |
public static final PotatoToolMaterial INSTANCE = new PotatoToolMaterial(); | public static final PotatoToolMaterial INSTANCE = new PotatoToolMaterial(); | ||
Line 86: | Line 86: | ||
[...] | [...] | ||
} | } | ||
- | </code> | + | </yarncode> |
'' | '' | ||
Line 92: | Line 92: | ||
==== Creating Tools ==== | ==== Creating Tools ==== | ||
- | All base tool classes ('' | + | All base tool classes ('' |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
- | public static | + | public static |
- | public static | + | public static |
- | </code> | + | </yarncode> |
- | `PickaxeItem` | + | ''< |
- | <code java [enable_line_numbers=true]> | + | <yarncode |
- | public class CustomPickaxeItem extends | + | public class CustomPickaxeItem extends |
- | public CustomPickaxeItem(ToolMaterial | + | public CustomPickaxeItem(class_1832 |
super(material, | super(material, | ||
} | } | ||
} | } | ||
- | </code> | + | </yarncode> |
- | Using the custom subclass: | + | Using the public classes: |
- | <code java> | + | <yarncode |
- | public static | + | public static |
- | public static | + | public static |
- | public static | + | public static |
- | </code> | + | </yarncode> |
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. | 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. |
tutorial/tools.txt · Last modified: 2024/08/23 13:25 by solidblock