Block Drops and Tags – Architectury API Multiplatform Modding

I have shown how to add Blocks in an earlier part of this series. But these Blocks instantly break when hit even in Survival Mode and they don’t drop anything. In this part you’ll learn how to change this and make our Ruby Block drop itself, and our Ruby Ore drop Rubys depending also on the fortune level of the pickaxe used to break it.

Additional Resources

The Tutorial Mod used here can be found on GitHub (state after this tutorial).
A video version can be found below.

Contents

  1. Block Drops
  2. Block Properties
  3. Block Tags
  4. Video

Block Drops

As I explained in the last part about Recipes, our mod has an integrated datapack. We specify drops for our blocks through loot-tables in said databack. Therefore we need to place the Json-Files with the loot-table information in the resources/data/<mod_id>/loot_table/blocks/ folder. If you just want your block to drop itself, like our Ruby Block, you’ll need at least the following in your ruby_block.json (your blocks id) file:

Important for us are here the rolls, which specify how often an entry from the entries list is picked. If you always want one drop, you specify 1 here. Furthermore since we only want our block itself to drop, we only specify one entry so that it is always picked. Each entry consists of the type, here item, and the name, which is the item ID.

For our Ruby Ore we use the following loot-table definition:

As you can see, we changed the entry to give as a Ruby. Additionally there is a new parameter bonus_rolls. It is relevant for tools enchanted with Fortune with each level of the enchantment adding this number of rolls. So if we use a Fortune II pickaxe, we will always get 2 Rubys. If you want a random amount of drop, instead of specifying the number, you can specify a range:

With this we would always get 1 or 2 Rubys and for each level of Fortune 0.5 to 2.5 more.

Block Properties

Now our blocks drop things, but they still break instantly. We need to modify our Block Properties to change this. Until now when we register a block we call our baseProperties(…) helper method. We can append additional modfiers to our properties behind it, like this:

The first change is requiredCorrectToolForDrops(). We use this to make sure our block can only drop items if broken with the correct tool we define in the next step. If you want your block to always drop, you can omit this. The second modification is the strength() of our block. There are two different options for this method. One which sets both manual and explosion resistance to the same value and another one which allows you to specify both values individually. For reference: Regular Diamond Ore has for both of these a value of 3.

Block Tags

Next we will add tags to our blocks that specify the tool and tool level required for dropping items. These tags are specified in Minecrafts internal datapack, so we will need to modify it. To specify our tool type required for breaking we need to create a directory resources/data/minecraft/tags/block/mineable. Furthermore we create a json-File for the desired tool type, in this case pickaxe.json, with the following content:

With the first line we specify that we want to add to the vanilla datapack and not replace it. Additionally we specify the values we want to add, in this case both our Ruby Block and our Ruby Ore. With this our block will break faster when mined with a pickaxe compared to all other tools. If you want a minimal level of the tool to be required as well, the corresponding files are found in the resources/data/minecraft/tags/block directory. If you want an iron tool or higher to be required, you need to add your blocks to the needs_iron_tool.json tag in the same way as above. Files for all other tool levels are named accordingly.

Now you know how to add drops to your block. Additionally you know how to configure your block to require a certain tool and tool level to drop. Next we’re going to add our own tools to the game.

Video

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

Related Content

Check out the entire series here.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top