How to make a pickaxe in a Minecraft mod
A pickaxe is a tool item made of a tier (a ToolMaterial from 1.21.2), which sets its durability, mining speed and the blocks it can’t mine, plus attack damage and speed attributes. Before 1.21.5 it is a PickaxeItem (ItemPickaxe on 1.12.2); from 1.21.5 it is a plain Item made a pickaxe through Item.Properties#pickaxe. Its item model is held like a tool, and the #minecraft:pickaxes tag, where the version has it, lets it take pickaxe enchantments.
Works on Minecraft 1.20.1 to 26.3 on NeoForge; Minecraft 1.16.5 to 26.3 on Fabric; Minecraft 1.16.5 to 1.20.1 on Forge; Minecraft 1.12.2 on Forge. Each example was compiled against its loader and version before it shipped in Linen.
- Make the pickaxe with your tier and attributes (a class that extends PickaxeItem before 1.21.5, Item.Properties#pickaxe after).
- Register it with your class.
- Use the item/handheld model parent.
- Add it to the #minecraft:pickaxes item tag (not on 1.16.5 and older).
What you can change
Section titled “What you can change”The example uses these values. Change them in the code.
| Setting | In the example | What it does |
|---|---|---|
| tier | IRON |
The vanilla tier it is made of: its durability, speed and what it can mine. |
| damage | 1 |
Attack damage on top of the tier’s (vanilla pickaxes 1). |
| speed | -2.8 |
Attack speed change (vanilla pickaxes -2.8). |
For each loader and version
Section titled “For each loader and version”The example mod is examplemod in the package com.example.examplemod. Use your own mod id and package.
Fabric and NeoForge 1.20.1 to 1.20.4, Fabric 1.16.5 to 1.20, Forge 1.17.1 to 1.20.1
Section titled “Fabric and NeoForge 1.20.1 to 1.20.4, Fabric 1.16.5 to 1.20, Forge 1.17.1 to 1.20.1”Uses:
PickaxeItemTiersItemTags.PICKAXES
src/main/java/com/example/examplemod/item/RubyPickaxeItem.java
package com.example.examplemod.item;
import net.minecraft.world.item.Item;import net.minecraft.world.item.PickaxeItem;import net.minecraft.world.item.Tiers;
// Ruby Pickaxe: a IRON pickaxe; what it can mine and how fast come from the tier.public class RubyPickaxeItem extends PickaxeItem { public RubyPickaxeItem(Item.Properties properties) { super(Tiers.IRON, (int) 1.0F, -2.8F, properties); }}In src/main/resources/data/minecraft/tags/items/pickaxes.json, add this to the list at /values:
"examplemod:ruby_pickaxe"It’s registered like any other item, as RubyPickaxeItem: see a new item.
Fabric and NeoForge 1.20.5 to 1.20.6
Section titled “Fabric and NeoForge 1.20.5 to 1.20.6”Uses:
PickaxeItemDiggerItem.createAttributesTiersItemTags.PICKAXES
src/main/java/com/example/examplemod/item/RubyPickaxeItem.java
package com.example.examplemod.item;
import net.minecraft.world.item.DiggerItem;import net.minecraft.world.item.Item;import net.minecraft.world.item.PickaxeItem;import net.minecraft.world.item.Tiers;
// Ruby Pickaxe: a IRON pickaxe; what it can mine and how fast come from the tier.public class RubyPickaxeItem extends PickaxeItem { public RubyPickaxeItem(Item.Properties properties) { super(Tiers.IRON, properties.attributes(DiggerItem.createAttributes(Tiers.IRON, 1.0F, -2.8F))); }}In src/main/resources/data/minecraft/tags/items/pickaxes.json, add this to the list at /values:
"examplemod:ruby_pickaxe"It’s registered like any other item, as RubyPickaxeItem: see a new item.
Fabric and NeoForge 1.21 to 1.21.1
Section titled “Fabric and NeoForge 1.21 to 1.21.1”Uses:
PickaxeItemDiggerItem.createAttributesTiersItemTags.PICKAXES
src/main/java/com/example/examplemod/item/RubyPickaxeItem.java
package com.example.examplemod.item;
import net.minecraft.world.item.DiggerItem;import net.minecraft.world.item.Item;import net.minecraft.world.item.PickaxeItem;import net.minecraft.world.item.Tiers;
// Ruby Pickaxe: a IRON pickaxe; what it can mine and how fast come from the tier.public class RubyPickaxeItem extends PickaxeItem { public RubyPickaxeItem(Item.Properties properties) { super(Tiers.IRON, properties.attributes(DiggerItem.createAttributes(Tiers.IRON, 1.0F, -2.8F))); }}In src/main/resources/data/minecraft/tags/item/pickaxes.json, add this to the list at /values:
"examplemod:ruby_pickaxe"It’s registered like any other item, as RubyPickaxeItem: see a new item.
Fabric and NeoForge 1.21.2 to 1.21.4
Section titled “Fabric and NeoForge 1.21.2 to 1.21.4”Uses:
PickaxeItemToolMaterialItemTags.PICKAXES
src/main/java/com/example/examplemod/item/RubyPickaxeItem.java
package com.example.examplemod.item;
import net.minecraft.world.item.Item;import net.minecraft.world.item.PickaxeItem;import net.minecraft.world.item.ToolMaterial;
// Ruby Pickaxe: a IRON pickaxe; what it can mine and how fast come from the tier.public class RubyPickaxeItem extends PickaxeItem { public RubyPickaxeItem(Item.Properties properties) { super(ToolMaterial.IRON, 1.0F, -2.8F, properties); }}In src/main/resources/data/minecraft/tags/item/pickaxes.json, add this to the list at /values:
"examplemod:ruby_pickaxe"It’s registered like any other item, as RubyPickaxeItem: see a new item.
Fabric and NeoForge 1.21.5 to 26.3
Section titled “Fabric and NeoForge 1.21.5 to 26.3”Uses:
Item.Properties.pickaxeToolMaterialItemTags.PICKAXES
Since 1.21.5 there is no PickaxeItem: Item.Properties#pickaxe(material, damage, speed) makes a plain Item a pickaxe.
src/main/java/com/example/examplemod/item/RubyPickaxeItem.java
package com.example.examplemod.item;
import net.minecraft.world.item.Item;import net.minecraft.world.item.ToolMaterial;
// Ruby Pickaxe: a IRON pickaxe; what it can mine and how fast come from the tier.public class RubyPickaxeItem extends Item { public RubyPickaxeItem(Item.Properties properties) { super(properties.pickaxe(ToolMaterial.IRON, 1.0F, -2.8F)); }}In src/main/resources/data/minecraft/tags/item/pickaxes.json, add this to the list at /values:
"examplemod:ruby_pickaxe"It’s registered like any other item, as RubyPickaxeItem: see a new item.
Forge 1.16.5
Section titled “Forge 1.16.5”Uses:
PickaxeItemItemTier
The minecraft:swords and minecraft:pickaxes item tags do not exist in 1.16.5: the item class (SwordItem, PickaxeItem) decides what it can do.
src/main/java/com/example/examplemod/item/RubyPickaxeItem.java
package com.example.examplemod.item;
import net.minecraft.item.Item;import net.minecraft.item.PickaxeItem;import net.minecraft.item.ItemTier;
// Ruby Pickaxe: a IRON pickaxe; what it can mine and how fast come from the tier.public class RubyPickaxeItem extends PickaxeItem { public RubyPickaxeItem(Item.Properties properties) { super(ItemTier.IRON, (int) 1.0F, -2.8F, properties); }}It’s registered like any other item, as RubyPickaxeItem: see a new item.
Forge 1.12.2
Section titled “Forge 1.12.2”Uses:
ItemPickaxeToolMaterial
src/main/java/com/example/examplemod/item/RubyPickaxeItem.java
package com.example.examplemod.item;
import com.google.common.collect.Multimap;import net.minecraft.entity.SharedMonsterAttributes;import net.minecraft.entity.ai.attributes.AttributeModifier;import net.minecraft.inventory.EntityEquipmentSlot;import net.minecraft.item.ItemPickaxe;
// Ruby Pickaxe: a IRON pickaxe; what it can mine and how fast come from the tier.public class RubyPickaxeItem extends ItemPickaxe { public RubyPickaxeItem() { super(ToolMaterial.IRON); }
// 1.12.2: damage and attack speed are attribute modifiers of the main hand; the material gives the base damage. @Override public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot slot) { Multimap<String, AttributeModifier> map = super.getItemAttributeModifiers(slot); if (slot == EntityEquipmentSlot.MAINHAND) { map.removeAll(SharedMonsterAttributes.ATTACK_DAMAGE.getName()); map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 1.0F + toolMaterial.getAttackDamage(), 0)); map.removeAll(SharedMonsterAttributes.ATTACK_SPEED.getName()); map.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.8F, 0)); } return map; }}It’s registered like any other item, as RubyPickaxeItem: see a new item.
Sources
Section titled “Sources”- https://docs.fabricmc.net/1.21.1/develop/items/custom-tools
- https://docs.neoforged.net/docs/1.21.1/items/tools
Related how-tos
Section titled “Related how-tos”In Linen
Section titled “In Linen”Linen’s How-tos library has this page too, with the example for your own mod’s loader and Minecraft version. Hover a name in your code and Linen points to the how-tos that explain it. Both are free. Download Linen.