In this guide you will make two things from rubies: a Ruby Sword that hits harder than iron, and a Ruby Pickaxe that mines stone and ores quickly. Along the way you will learn the components every weapon and tool uses: damage, durability, enchanting, repairing and digging.
This guide builds on Your first custom item. The icon, texture and name steps work the same, so we will focus on what is new.
The quick way: GodCraft
GodCraft has ready-made Sword and Tool objects. You pick numbers, it writes the components and the tags.
- Open the Workshop and add a Sword or a Tool to your add-on.
- Draw it in the pixel editor (diagonal, handle at the bottom left, like vanilla tools).
- Set the damage, durability, repair items and enchantments.
- Tap Export and try it on the nearest zombie.
Here is what that looks like by hand.
By hand: the sword
We use the namespace myname. Replace it with your own everywhere.
{
"format_version": "1.26.30",
"minecraft:item": {
"description": {
"identifier": "myname:ruby_sword",
"menu_category": {
"category": "equipment",
"group": "minecraft:itemGroup.name.sword"
}
},
"components": {
"minecraft:icon": {
"textures": {
"default": "myname_ruby_sword"
}
},
"minecraft:display_name": {
"value": "item.myname:ruby_sword.name"
},
"minecraft:max_stack_size": 1,
"minecraft:hand_equipped": true,
"minecraft:damage": 7,
"minecraft:durability": {
"max_durability": 900
},
"minecraft:enchantable": {
"slot": "sword",
"value": 14
},
"minecraft:repairable": {
"repair_items": [
{
"items": ["myname:ruby"],
"repair_amount": "query.max_durability * 0.25"
},
{
"items": ["myname:ruby_sword"],
"repair_amount": "context.other->query.remaining_durability"
}
]
},
"minecraft:tags": {
"tags": ["minecraft:is_sword"]
}
}
}
}What each part does
menu_categoryputs the sword in the Equipment tab, inside the same folder as the vanilla swords.minecraft:max_stack_sizeset to 1, because weapons do not stack.minecraft:hand_equippedmakes the player hold it like a tool, pointing forward, instead of like a flat item.minecraft:damageis how much damage the item adds when you attack with it. Higher is stronger. Start around 7 for a diamond-like sword, then test it on a few mobs and adjust.minecraft:durabilityis how much wear the item can take before it breaks. Iron tools have 250, diamond 1561. You can also adddamage_chancewith aminandmaxpercentage, if you want it to only lose durability some of the time.minecraft:enchantabledecides which enchantments fit.slotis the kind of item (swordhere) andvalueis how good the enchantments are on a table: gold is very high, stone is low, 14 is a solid middle.minecraft:repairablelists what can repair it on an anvil. Each entry has theitemsand arepair_amount, which is a small Molang formula. The first entry gives back a quarter of the durability per ruby. The second one lets players combine two damaged swords.minecraft:tagswithminecraft:is_swordtells the game and other add-ons that this is a sword.
Texture and name
Save a 16x16 PNG at RP/textures/items/ruby_sword.png, then add it to your item_texture.json (inside texture_data) and the name to your lang file:
"myname_ruby_sword": {
"textures": "textures/items/ruby_sword"
}item.myname:ruby_sword.name=Ruby Sword
item.myname:ruby_pickaxe.name=Ruby PickaxeBy hand: the pickaxe
A tool is a weapon with one more job: breaking blocks fast. That job belongs to minecraft:digger.
{
"format_version": "1.26.30",
"minecraft:item": {
"description": {
"identifier": "myname:ruby_pickaxe",
"menu_category": {
"category": "equipment",
"group": "minecraft:itemGroup.name.pickaxe"
}
},
"components": {
"minecraft:icon": {
"textures": {
"default": "myname_ruby_pickaxe"
}
},
"minecraft:display_name": {
"value": "item.myname:ruby_pickaxe.name"
},
"minecraft:max_stack_size": 1,
"minecraft:hand_equipped": true,
"minecraft:damage": 5,
"minecraft:durability": {
"max_durability": 900
},
"minecraft:enchantable": {
"slot": "pickaxe",
"value": 14
},
"minecraft:repairable": {
"repair_items": [
{
"items": ["myname:ruby"],
"repair_amount": "query.max_durability * 0.25"
}
]
},
"minecraft:digger": {
"use_efficiency": true,
"destroy_speeds": [
{
"block": {
"tags": "query.any_tag('stone', 'metal')"
},
"speed": 7
},
{
"block": "minecraft:obsidian",
"speed": 7
}
]
},
"minecraft:tags": {
"tags": ["minecraft:is_pickaxe", "minecraft:is_tool", "minecraft:diamond_tier"]
}
}
}
}How digging works
destroy_speedsis a list. Each entry says which blocks and how fast.blockcan be one block ID, like"minecraft:obsidian", or an object withtagsand a Molang query.query.any_tag('stone', 'metal')matches every block that has at least one of those tags, so you do not have to list hundreds of blocks.speedis how fast it breaks those blocks. For a feel: wood tools are 2, stone 4, iron 6, diamond 8, netherite 9 and gold 12.use_efficiencyset totruelets the Efficiency enchantment make it even faster.
Tags for tools
The tags tell Minecraft what kind of tool this is. minecraft:is_pickaxe and minecraft:is_tool say "this is a pickaxe". A tier tag like minecraft:iron_tier or minecraft:diamond_tier says how strong it is, the same tags vanilla tools use. Other kinds of tool use minecraft:is_axe, minecraft:is_shovel or minecraft:is_hoe.
Making an axe or shovel instead
Copy the pickaxe, then change three things: the slot in minecraft:enchantable (axe or shovel), the block tags in destroy_speeds (for example 'wood' for an axe, 'dirt', 'sand' and 'gravel' for a shovel) and the is_ tag.
Test it
- Load your packs into a new world (see Export and install).
- Give yourself both items with /give:
/give @s myname:ruby_sword
/give @s myname:ruby_pickaxe- Hit a mob, mine some stone, and try enchanting both on a table.
- Damage them a little, then put one on an anvil with a ruby to test repairing.
Enchantment slots you can use
slot | Enchants like |
|---|---|
sword | A sword |
axe, pickaxe, shovel, hoe | That tool |
bow, crossbow | A ranged weapon |
g_tool | Any tool |
g_digging | Any digging tool |
all | Anything |
When something goes wrong
| What you see | Most likely cause |
|---|---|
| The item is held flat like a stick of paper | minecraft:hand_equipped is missing |
| It mines as slowly as your fist | The block tags in destroy_speeds do not match, or the Molang query has a typo |
| It cannot be enchanted | minecraft:enchantable is missing, or slot is spelled wrong |
| The anvil will not repair it | The item ID in repair_items is wrong |
More fixes are in Troubleshooting. To let players craft these, read Crafting and furnace recipes, and for the matching armor, see Custom armor.