How to make a block need a certain tool in a Minecraft mod
Which tool mines a block fast is a tag: minecraft:mineable/pickaxe, axe, shovel or hoe. Which tier it needs is another tag: needs_stone_tool, needs_iron_tool, needs_diamond_tool. Both are files under data/minecraft/tags/block (tags/blocks before 1.21) that list your block. The block’s properties also need requiresCorrectToolForDrops(), or it drops with any tool.
Works on Minecraft 1.20.1 to 26.3 on NeoForge; Minecraft 1.17.1 to 1.20.1 on Forge; Minecraft 1.17 to 26.3 on Fabric. Each example was compiled against its loader and version before it shipped in Linen.
- Add .requiresCorrectToolForDrops() to the block’s properties.
- List the block in the mineable tag for its tool.
- List it in the needs_<tier>_tool tag.
- Try breaking it with the wrong tool, then the right one.
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 |
|---|---|---|
| tool_tag | mineable/pickaxe |
The tool that mines it fast. |
| tier_tag | needs_iron_tool |
The tier it needs. |
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.4 to 1.20.6, NeoForge 1.20.1 to 1.20.2, Fabric 1.17 to 1.20.3, Forge 1.17.1 to 1.20.1
Section titled “Fabric and NeoForge 1.20.4 to 1.20.6, NeoForge 1.20.1 to 1.20.2, Fabric 1.17 to 1.20.3, Forge 1.17.1 to 1.20.1”Uses:
minecraft:mineable/pickaxeminecraft:needs_iron_toolBlockTags.MINEABLE_WITH_PICKAXE
In src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json, add this to the list at /values:
"examplemod:ruby_block"In src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json, add this to the list at /values:
"examplemod:ruby_block"Fabric and NeoForge 1.21 to 26.3
Section titled “Fabric and NeoForge 1.21 to 26.3”Uses:
minecraft:mineable/pickaxeminecraft:needs_iron_toolBlockTags.MINEABLE_WITH_PICKAXE
In src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json, add this to the list at /values:
"examplemod:ruby_block"In src/main/resources/data/minecraft/tags/block/needs_iron_tool.json, add this to the list at /values:
"examplemod:ruby_block"Sources
Section titled “Sources”- https://docs.neoforged.net/docs/1.21.1/resources/server/tags
- https://docs.neoforged.net/docs/1.21.1/blocks/
- https://docs.fabricmc.net/develop/
Related how-tos
Section titled “Related how-tos”- A tool tier of your own
- Generate block tags with datagen
- An item tag
- A crafting recipe
- A new enchantment
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.