Loot Tables
Loot tables are data files that are used to define randomized loot drops. A loot table can be rolled, returning a (potentially empty) list of item stacks. The output of this process depends on (pseudo-)randomness. Loot tables are located at data/<mod_id>/loot_table/<name>.json. For example, the loot table minecraft:blocks/dirt, used by the dirt block, is located at data/minecraft/loot_table/blocks/dirt.json.
Minecraft uses loot tables at various points in the game, including block drops, entity drops, chest loot, fishing loot, and many others. How a loot table is referenced depends on the context:
- Every block will, by default, receive an associated loot table, located at
<block_namespace>:blocks/<block_name>. This can be disabled by calling#noLootTableon the block'sProperties, resulting in no loot table being created and the block dropping nothing; this is mainly done by air-like or technical blocks. - Every entity that does not call
EntityType.Builder#noLootTable(which is typically entities inMobCategory#MISC) will, by default, receive an associated loot table, located at<entity_namespace>:entities/<entity_name>. This can be changed by overriding#getLootTable. For example, sheep use this to roll different loot tables depending on their wool color. - Chests in structures specify their loot table in their block entity data. Minecraft stores all chest loot tables in
minecraft:chests/<chest_name>; it is recommended, but not required to follow this practice in mods. - The loot tables for gift items that villagers may throw at players after a raid are defined in the
neoforge:raid_hero_giftsdata map. - Other loot tables, for example the fishing loot table, are retrieved when needed from
level.getServer().reloadableRegistries().getLootTable(lootTableKey). A list of all vanilla loot table locations can be found inBuiltInLootTables.
Loot tables should generally only be created for stuff that belongs to your mod. For modifying existing loot tables, global loot modifiers (GLMs) should be used instead.
Due to the complexity of the loot table system, loot tables are compromised of several sub-systems that each have a different purpose.