Custom loot Tables

Loot tables are powerful tools that define what block drop upon destruction, what entities upon death, what equipment can entities use, what can a player fish out of a river and what loot ends up in the game's loot chests. In order to understand loot tables better, I recommend looking into the loot_tables folder of the Example Vanilla Behavior pack, but I'll trow in some examples from there into here nevertheless (you can scroll down or to the sides for better readability).

One can even make a loot that drops half-removed blocks like glowingobsidian and netherreactors!

The most important thing in a loot table is the file name, since loot tables have no other identifier. They can be called by the path of the file in bhv/blocks/blockname.json/"minecraft:loot: {}" for block loot, bhv/entities/entityname.json/"minecraft:loot: {}" for entities and bhv/entities/entityname.json/"minecraft:equipment: {}" for entity equipment (most hostile mobs use low_tier_items.json).

If you want to change what can a player fish out of a jungle river, simply create your own loot table under bhv/loot_tables/gameplay/fishing/jungle_fish.json and bhv/loot_tables/gameplay/fishing/jungle_junk.json to overwrite the Vanilla loot tables. This can be done with most other Vanilla files too (if the aspect is data-driven).

You can aslo use loot_tables.empty.json for no loot.

Let's break up the Loot table structure somewhat. I took a simple zombie loot table as an example.

  • "rolls" defines how many times a random entry will be chosen from the following "entries" object.

  • "type" can be set to either "item" or "loot_table" (to refer to an external loot table. For more information on that, check the Vanilla bhv/loot_tables/gameplay/fishing.json).

  • "name" only goes after "type": "item" and can be set to an item's full identifier, including the namespace.

  • "weight" is the chance of this entry being chosen. The higher the weight in comparison to other entries in this "entries" array, the higher the chance of the entry being chosen.

  • "functions" are what makes loot tables so powerful. They can do a lot, including setting the number of items dropped, enchanting the items(enchantments can even go on normally non-enchantable items that way), setting the items' names, the items' lores, and even writing books. For more information on functions check the example vanilla files or the unofficial Loot Table documentation, available in the Links and Contact page or here.

  • "conditions" can check for things like "was the entity killed by a player?" and "was the sword enchanted with Looting III?". More info in them can be found in the resources listed above.

Blocks do not drop loot in creative mode

Note: it is possible to generate loot tables visually online. Check Links and Contact for the link to a reliable generator.

Challenge: Create custom loot tables for our custom blocks created in the previous chapter!

Custom crafting/smelting/etc Recipes

Notes: Recipes will only work with [EX] enabled! A BDS extension was able to provide custom crafting in the past as well;

Recipes can have unique identifiers like tut:compass_from_compass_block. They're located in bhv/recipes.

  • The parameter below "format_version" defines the type of this recipe. It can be set to "recipe_furnace"(smelting), "recipe_shaped"(every ingredient has a set place in the crafting grid) and "recipe_shapeless"(ingredients can be placed in whatever order into the crafting grid).

  • Every recipe takes "tags" which are a list of vanilla benches that can use this recipe. Can be "crafting_table", "furnace", "smoker", "blast_furnace", "campfire", "stonecutter" etc.

Let's look through some recipe-specific syntax next.

This is a smelting recipe.

  • "input":
    "item": the item's to be smelted full identifier;
    "data": it's aux value. Default: 0;

"count" is optional. It most likely has something to do with the number of items that can be smelted at the same time in a campfire, but it isn't documented anywhere.

  • "output": the item that the furnace outputs after smelting.

This is a shaped recipe.

  • "pattern" consists of 3 rows each consisting of 3 character keys. Each character symbolizes an item in a slot of the crafting grid.

  • "key" defines each character to mean an item. Here, 'P' means a Wooden Shovel and '#' means a 'planks' block with aux value 4, which is the Acacia Planks block.

  • "result" means same as output. Her it's an Acacia Boat('boat' with aux id 4).

These are shapeless recipes.

  • "priority" is the priority with which the recipe will be chosen over others.

  • "ingredients" is simply a list of all ingredients with their aux values. There are no keys, since the ingredients can be placed in any crafting grid slot.

Note: Crafting recipes can be generated visually online, check Links and Contact for a stable generator.

Challenge: Create custom crafting/smelting recipes for our custom blocks and items created in previous chapters!

Spawn Rules

Spawn rules define how vanilla Entities and custom entities spawn. In the next chapter we'll be creating a custom entity, so make sure to prepare a custom spawn rule for it! Check out the vanilla example files for more information. ;)

  • "description">"identifier": the entity to spawn"population_control": controls spawning and despawning quantities. Can be set to "animal", "underwater_animal", "monster" and "ambient".

  • "conditions" are a list of conditions that have to be met in order for the spawn attempt to succeed.

  • "minecraft:spawns_on_surface", "minecraft:spawns_underground" and "minecraft:spawns_underwater" control where the entity spawns cap-wise.

  • "minecraft_brightness_filter" can be set from 0 to 15 and controls in which light levels can entities spawn. "adjust_for_weather" defines whether it light levels are counted lower during rain or thunder weather.

  • "minecraft:difficulty_filter" sets the range of level difficulty to enable this entity's spawns.

  • "minecraft:herd" sets the number of entities spawning together, on the same spawn rule.

  • "minecraft:permute_type" with "weight"s and "entity_type"s sets a chance for the spawned entity to mutate into a different one.

And, lastly, "minecraft:biome_filter" tests for certain biome tags. Look up the filter syntax and list of biome tags in the documentation or search examples in the vanilla Example pack.

  • "minecraft:herd" can also be used like this to make the second entity spawned [in this scenario] with the "minecraft:entity:born" (as baby). Can be used in any event.
    "event_skip_count": 2, for example, means that the first two entities will not be spawned with this event, but all the next ones will.

Why not create some more custom blocks, items, recipes and loot tables before moving onto the next big chapter?

Your progress so far:

What you've done:

  • Learned to create Loot Tables;

  • Learned to create custom Recipes of different types;

  • Learned to create spawn rules;

  • Created Recipes and Loot Tables for our custom blocks and items;

  • Learned about the usefulness referencing the Example files and the documentation even better;

  • Tried out some online file generators;

What are you to do next:

  • Create. Custom. Entities.