Loot Tables are a technical feature that were added in Update 0.16.0.
Usage[]
Loot Tables represent what Mobs drop, what Items should be in Naturally Generated Containers, and what Items can be Fished. Players can use this to manipulate Mob's drops, Chests, etc.
Technical Information[]
The best way to understand Loot Tables is to read the json
files from the Vanilla Behavior Pack. Especially interesting are the files in the folder loot_tables/chests
. These files, as most behavior and resource pack file are in json format, which is too much to explain here.
The overall structure of each of these files are:
pools
– A table of each of the various loot groups- Each loot group has:
rolls
– To indicate how many times they pick items from the entriesentries
– The weighted list of possible items to include
- Each entry has:
type
andname
– An identificatorweight
– Used for randomisation- Optional
functions
– One or more functions used for specifying count (other than a single item), specify data variation, or to enchant the item in question.
Some specific functions which are often seen are:
set_count
– Defines themin
andmax
amount of that particular itemset_data
– Used to set which variant, usingdata
, of the item to include. Often used to distinguish which wood or sapling to includeenchant_with_levels
– Indicates that enchantments are to be applied, and which correspondinglevels
to use for these.
To generate loot the game goes through each of the loot groups, and repeats the choosing of items the number of times specified by the rolls
parameter. To actually choose an item, it chooses a random number with a maximum of the summed weight
's, and picks the corresponding item. Finally it applies the functions of that chosen item, and adds it to the loot.
For an in-depth example see Tutorial:Loot Table Example.