First we'll need to create a tool material for our new tools to use. We'll use Forge's `EnumHelper` class to add a value to the Minecraft `Item.ToolMaterial` enum.
```java
// ...
public class TutorialMod {
// ...
public static final Item.ToolMaterial copperToolMaterial = EnumHelper.addToolMaterial("COPPER", 2, 500, 6, 2, 14);
// ...
}
```
Each tool is going to be quite similar, so feel free to skip ahead to the one you want.
- [Sword](#sword)
- [Pickaxe](#pickaxe)
- [Axe](#axe)
- [Shovel](#shovel)
- [Hoe](#hoe)
## Sword
First we'll create an `ItemSword` class in the `item.tool` package inside our mod package. This class will extend the vanilla `ItemSword` class and implement our `ItemModelProvider` interface.
In the constructor, we'll:
- Call the `super` constructor with the tool material
- Set the unlocalized and registry names
- Store the name for use in item model registration
We'll also override `registerItemModel` and use the stored `name` to register our item model.
We'll also create our JSON item model at `assets/tutorial/models/item/copperSword.json`. Unlike our other item models, the parent for the model will be `item/handheld` instead of `item/generated`. `item/handheld` provides the transformations used by handheld items, such as tools.
```json
{
"parent": "item/handheld",
"textures": {
"layer0": "tutorial:items/copperSword"
}
}
```
We'll also need the texture, which you can download [here](https://raw.githubusercontent.com/shadowfacts/TutorialMod/1.10.2/src/main/resources/assets/tutorial/textures/items/copperSword.png).
And lastly, we'll add a localization entry for the sword.
Let's create an `ItemPickaxe` class in the `item.tool` package of our mod. This class will extend the vanilla `ItemPickaxe` and implement our `ItemModelProvider` interface.
In our `ItemPickaxe` constructor we'll:
- Call the `super` constructor with the tool material
- Set the unlocalized name and registry names
- Store the name for use in the item model registration
We'll also override `registerItemModel` and use the stored `name` field to register our item model.
We'll create a JSON model for our item at `assets/tutorial/models/item/copperPickaxe.json`. This model will have a parent of `item/handheld` instead of `item/generated` so it inherits the transformations for handheld models.
```json
{
"parent": "item/handheld",
"textures": {
"layer0": "tutorial:items/copperPickaxe"
}
}
```
You can download the texture for the copper pickaxe [here](https://raw.githubusercontent.com/shadowfacts/TutorialMod/1.10.2/src/main/resources/assets/tutorial/textures/items/copperPickaxe.png).
Lastly, we'll need a localization entry for the pick.
First off, we'll need an `ItemAxe` class that extends the vanilla `ItemAxe` class and implements our `ItemModelProvider` interface.
If you look at the vanilla `ItemAxe` class, you'll notice that it has two constructors. One of them takes only a `ToolMaterial` whereas the other takes a `ToolMaterial` and two `float`s. Only vanilla `ToolMaterial`s will work with the `ToolMaterial` only constructor, any modded materials will cause an `ArrayIndexOutOfBoundsException` because of the hardcoded values in the `float` arrays in the `ItemAxe` class. Forge provides the secondary constructor that accepts the two `float`s as well, allowing modders to add axes with their own tool materials.
In the `ItemPickaxe` constructor, we will:
- Call the `super` constructor with the tool material and the damage and attack speeds used by the vanilla iron axe.
- Set the unlocalized and registry names
- Store the name for use in the item model registration
Additionally, we'll override `registerItemModel` and use the stored `name` to register our model.
Additionally, we'll need a JSON item model. We'll create it at `assets/tutorials/models/item/copperAxe.json`.
Our model will have a parent of `item/handheld` instead of `item/generated` so it has the same transformations used by other hand-held items.
```json
{
"parent": "item/handheld",
"textures": {
"layer0": "tutorial:items/copperAxe"
}
}
```
You can download the texture for the copper axe [here](https://raw.githubusercontent.com/shadowfacts/TutorialMod/1.10.2/src/main/resources/assets/tutorial/textures/items/copperAxe.png).
Lastly, we'll need a localization entry for our axe.
Next, we'll create a JSON item model for our shovel at `assets/tutorial/models/item/copperShovel.json`. This model will have a parent of `item/handheld`, unlike our previous item models, so it inherits the transformations used by handheld items.
```json
{
"parent": "item/handheld",
"textures": {
"layer0": "tutorial:items/copperShovel"
}
}
```
You can download the texture for our shovel [here](https://raw.githubusercontent.com/shadowfacts/TutorialMod/1.10.2/src/main/resources/assets/tutorial/textures/items/copperShovel.png).
We'll also need a localization entry for our shovel.
Next, we'll create a JSON item model for our hoe at `assets/tutorial/models/item/copperHoe.json`. This model will have a parent of `item/handheld` instead of `item/generated` so it inherits the transformations used by vanilla handheld items.
```json
{
"parent": "item/handheld",
"textures": {
"layer0": "tutorial:items/copperHoe"
}
}
```
You can download the copper hoe texture [here](https://raw.githubusercontent.com/shadowfacts/TutorialMod/1.10.2/src/main/resources/assets/tutorial/textures/items/copperHoe.png).
Lastly, we'll need a localization entry for our hoe.