3.2 KiB
Tools
A tool is an item with a tool property. It breaks blocks of its type faster, lets players get drops from blocks that
require it, and wears out over time.
{
"format_version": 1,
"item": {
"id": "copper_tools:copper_pickaxe",
"texture": "copper_tools:copper_pickaxe",
"tool": { "type": "pickaxe", "tier": 1, "speed": 4, "durability": 5 }
}
}
| Field | Default | Meaning |
|---|---|---|
type |
required | Matched against blocks' mining.tool, like "pickaxe", "axe", "shovel", "hoe" or "knife". Any word works. |
durability |
required | How many uses it has before it breaks, see below. |
tier |
0 |
Compared with blocks' mining.tier. |
speed |
2 |
How many times faster than a hand it breaks blocks of its type. |
Tools stack to 1 unless they set max_stack.
Mining
A block breaks speed times faster when the held tool's type is the block's mining.tool. A block with
"requires_tool": true only drops when broken with a tool of its type whose tier is at least the block's
mining.tier. See Mining.
The base game's tiers:
| Tier | Tools | Durability | Gets drops from |
|---|---|---|---|
0 |
wood, gold | 2 (wood), 9 (gold) | stone, coal ore |
1 |
stone, copper | 3 (stone), 5 (copper) | also copper, tin, iron and gold ore |
2 |
iron | 7 | everything so far |
Tool types don't have to be the base game's. A mod can add a "sickle" type and blocks with "tool": "sickle", and a
server script can check a held item's type with ctx.items.tool(id), like the base game's bworld:hoeable does for
hoes. The base game's watering cans are tools of type "watering_can" that no block is mined with: they come in the
same five tiers with the same durability, and each holds more water than the last (16, 24, 32, 48 and 64), set by its
bworld:watering_can component.
Durability
Like Sunlit Valley, tools don't wear out from use. They lose durability when their owner dies: everything a player carries falls out where they died, and each tool loses 1 durability first. A tool that runs out breaks instead of dropping.
The damage a tool has taken is kept in its stack's data.damage, and a worn tool shows a bar under it in its slot,
going from green to red as it wears down. Upgrading a tool at the smithing table keeps its data, damage included.
A server script wears a tool down with ctx.items.damage(item, amount), which adds to the stack's data.damage and
returns true when that used it up. It does nothing to items that aren't tools. The base game's death drops use it.