How to make a block drop something in a Minecraft mod
What a block drops is data: its loot table, a JSON file in data/<modid>/loot_table/blocks named after the block (loot_tables/blocks before 1.21, and assets/<modid>/loot_tables/blocks on 1.12.2). A table can drop the block itself, another item, more with Fortune like the ores do, and the block itself with Silk Touch.
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 loot table file for the block (data/<modid>/loot_table/blocks/<block>.json, loot_tables before 1.21).
- Add a pool with an item entry for what it drops.
- For ores, add a Fortune bonus and a Silk Touch alternative.
- Break the block in survival to check.
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 |
|---|---|---|
| drops | minecraft:diamond |
The item it drops. |
| fortune | true |
Fortune gives more, like Minecraft’s ores. |
| silk_touch | true |
With Silk Touch it drops itself. |
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 1.16.5 to 26.3, NeoForge 1.20.1 to 26.3, Forge 1.16.5 to 1.20.1
Section titled “Fabric 1.16.5 to 26.3, NeoForge 1.20.1 to 26.3, Forge 1.16.5 to 1.20.1”Uses:
minecraft:alternativesminecraft:apply_bonusminecraft:match_tool
Forge 1.12.2
Section titled “Forge 1.12.2”Uses:
minecraft:itemminecraft:set_countminecraft:looting_enchant
In 1.12.2 a loot table is a file in assets/<modid>/loot_tables/blocks.
Sources
Section titled “Sources”Related how-tos
Section titled “Related how-tos”- A new block
- Add drops to Minecraft’s loot
- A block that can hold water
- A block that changes over time with random ticks
- A block that faces the player
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.