This gist covers the changes to loot tables introduced in 18w43a, the first 1.14 snapshot. Check out this more in-depth loot table guide.
Last updated: 18w49a
Loot tables need a type associated with them, used to validate the structure. Some functions and conditions can only be used in certain types. There are currently 7 loot table types: empty
, entity
, chest
, block
, fishing
, advancement_reward
and generic
.
There are three ways to specify an integer: constant
, uniform
and binomial
.
To specify an exact number, simply declare the parameter as an integer. The following sets the count to exactly 2.
"count": 2
- Parameters:
min
(float) andmax
(float) - Random value: uniform random value between
min
andmax
(inclusive) Thetype
parameter is optional here asuniform
is the default behavior. The following is a count object used inminecraft:blocks/glowstone
. The count will randomly be set to 2, 3 or 4 with an equal chance for each of them.
"count": {
"min": 2.0,
"max": 4.0,
"type": "minecraft:uniform"
}
- Parameters:
n
(int) andp
(float) - Random value: binomial distribution with n and p
The following is a count object used in
minecraft:blocks/melon
.
"count": {
"n": 3,
"p": 0.06666667,
"type": "minecraft:binomial"
}
Entries are added to pools and specify what item(s) to add to the drop. Entries can have different types. minecraft:item
drops a single item, minecraft:empty
drops nothing and minecraft:loot_table
includes a whole other loot table for that entry. With 1.14, a few new entry types got added.
The minecraft:tag
type takes items from an item tag file. It can do two things depending on its expand
tag. If expand
is true, it chooses one item from the tag, all with same weight and quality. If expand
is false, it drops all the items in that tag. This entry type is used in the creeper.json
entity loot table to drop a random music disc.
{
"type": "minecraft:tag",
"name": "minecraft:music_discs",
"expand": true
}
The minecraft:group
type has a children
array. It executes all entries if its own condition passes. This can be used to avoid writing the same condition for multiple entries. A group without any condition is the same as applying the entries directly to the parent of that group. It is currently not used in vanilla.
{
"type": "minecraft:group",
"children": [
{
// an entry
},
{
// another entry
}
]
}
The minecraft:alternatives
type is just like a group, except it only executes the first entry that is successful. Children are checked in order from top to bottom. This can be used if you want to check multiple conditions, but only return one item for that entry. It is used a lot in vanilla block loot tables.
{
"type": "minecraft:alternatives",
"children": [
{
// first entry
},
{
// if the first entry succeed, this entry will not be executed
}
]
}
The minecraft:sequence
type is again, just like a group, but this time it executes until the first entry fails. Children are checked in order from top to bottom. This entry type is currently not used in vanilla.
{
"type": "minecraft:sequence",
"children": [
{
// first entry
},
{
// if this entry fails, no later entry will be executed
},
{
// third entry
}
]
}
The minecraft:dynamic
type gets block specific drops. Currently implemented are minecraft:contents
, which is used setting the contents of a shulker box. Following is the entry from a shulker box. (The copy_nbt function has been cut out for simplicity sake and will be explained later)
{
"type": "minecraft:item",
"name": "minecraft:white_shulker_box",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
},
{
"function": "minecraft:set_contents",
"entries": [
{
"type": "minecraft:dynamic",
"name": "minecraft:contents"
}
]
}
]
}
A lot of new conditions have been added. Some of them only apply to certain loot table functions! Each code example is only the condition compound.
The minecraft:alternative
condition has a terms
array. the condition passes when one ore more of those terms succeeds. Every term is a condition. In vanilla, this is used for leaves dropping when the tool is either shears or a silk touch tool. The condition is available for all loot table types.
{
"condition": "minecraft:alternative",
"terms": [
{
// a condition
},
{
// another condition
}
]
}
The minecraft:inverted
condition passes when the condition in term
fails and the other way around. The condition is available for all loot table types.
{
"condition": "minecraft:inverted",
"term": {
// a condition
}
}
The minecraft:survives_explosion
condition has no parameters and simply passes if the item would survive an explosion. If there was no explosion, this condition always passes. If there was an explosion, the chance of passing depends on the distance to the explosion and the explosion radius. The condition is only available for the block loot table type. It used in most blocks in vanilla.
{
"condition": "minecraft:survives_explosion"
}
The minecraft:blockstate_property
condition checks for blockstates of the block. It has a block
parameter to check for the block id and it has a properties
parameter, which is a map of properties and their values. The condition is only available for the block loot table type. It is currently not used in vanilla. Following is an example of how to use this condition to check for a downwards facing hopper. If you apply this to the minecraft:blocks/hopper
loot table, this would make hoppers only drop when they are facing downwards.
{
"condition": "minecraft:block_state_property",
"block": "minecraft:hopper",
"properties": {
"facing": "down"
}
}
The minecraft:location_check
condition has a predicate
parameter. It uses the same structure as the location object for advancements. This condition is available for all loot table types. In vanilla, this is used to add bamboo as possible item when fishing in a jungle biome.
{
"condition": "minecraft:location_check",
"predicate": {
"biome": "minecraft:jungle"
}
}
The minecraft:weather_check
condition has two boolean parameters, raining
and thundering
. This condition is available for all loot table types. It is currently not used in vanilla. The following is a condition that checks if it is raining.
{
"condition": "minecraft:weather_check",
"raining": true
}
The minecraft:match_tool
condition has a predicate
parameter. It uses the same structure as the item object for advancements. This condition is only available for block and fishing loot table types. The following is a condition that tests for a silk touch tool.
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
The minecraft:entity_properties
was modified. It has a predicate
tag which uses the same structure as the entity_object for advancements. If the predicate
tag is empty, any entity is accepted, but an entity still has to be present. This can be used to check if blocks were broken by an entity. It also has an entity
parameter. The following checks if the killer entity is a skeleton.
{
"condition": "minecraft:entity_properties",
"predicate": {
"type": "#minecraft:skeletons"
},
"entity": "killer"
}
The minecraft:damage_source_properties
condition has a predicate
parameter, which matches the source of the damage. It uses the same structure as the damage object for advancements. This condition is only available for the entity loot table type. In vanilla, this is used to make turtles drop a bowl when killed by lightning.
{
"condition": "minecraft:damage_source_properties",
"predicate": {
"is_lightning": true
}
}
The minecraft:table_bonus
condition defines the chances of passing based on an enchantment level. It has two parameters, enchantment
for the enchantment id and chances
for a list of probabilities for each enchantment level, starting with 0 (not enchanted with the given enchantment id). This condition is only available for the block loot table type. In vanilla, this is used for leaves having a higher chance of dropping a sapling with a higher fortune enchantment.
{
"condition": "minecraft:table_bonus",
"enchantment": "minecraft:fortune",
"chances": [
0.05,
0.0625,
0.083333336,
0.1
]
}
A lot of new functions were added. Similar to conditions, some of them are only available for certain loot table types. Each code example is only the function.
The minecraft:copy_name
function copies the CustomName
tags to the display.Name
tag of the item. The source
tag needs to be set to block_entity
. This function is only available for the block loot table type. In vanilla, this is used to copy the name of most container blocks and some other blocks to their dropped item.
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
The minecraft:set_name
was modified. It now allows an entity
parameter. If present, the name will be resolved with that entity. It allows using selector and score components. The following sets the name of the item to the killer's name.
{
"function": "minecraft:set_name",
"entity": "killer"
}
The minecraft:explosion_decay
function is related to the minecraft:survives_explosion
condition, but instead of canceling the entry completely, it removes some items from the item stack. Each item in the stack is processed separately. This function is only available for the block loot table type.
{
"function": "minecraft:explosion_decay"
}
The minecraft:limit_count
function limits the count of every item stack to a range. This function is available for all loot table types. In vanilla, this is used in blocks like glowstone and melon to prevent them from dropping more items than required to craft the block.
{
"function": "minecraft:limit_count",
"limit": {
"max": 9
}
}
The minecraft:set_contents
function sets the contents of the item to an entry. It has an entries
parameter which specifies which items get put in the contents of the item. The the entry can be a dynamic
type causing the contents to be copied. This function is only available for the block tool table type and only for containers. In vanilla, this is used for shulker boxes to copy the contents to the dropped item.
{
"function": "minecraft:set_contents",
"entries": [
{
"type": "minecraft:dynamic",
"name": "minecraft:contents"
}
]
}
The minecraft:set_lore
function sets the lore of the item. It has 3 tags. lore
is a list of text components, one for each line. A line of lore can also include a json list itself. selector
, score
and nbt
tag can be used as well, using the entity
tag context. This tag can be set to this
, killer
and direct_killer
. It also has a replace
tag. If true
, it will replace any existing lore, from other functions like set_contents
. If false
, it will append to the lore list.
{
"function": "minecraft:set_lore",
"lore": [
{"text":"Lore textcomponents!","color":"red"},
[{"text":"My name is ","color":"gold"}, {"selector":"@s"}]
],
"entity": "this",
"replace": "true"
}
The minecraft:fill_player_head
function adds the item tags for a player_head
given an entity
, which is most likely set to this
.
{
"function": "minecraft:fill_player_head",
"entity": "this"
}
The minecraft:copy_nbt
function copies nbt from a source to the item. It has 2 parameters, source
, where to get the nbt from, one of block_entity
, this
, killer
, killer_player
and ops
, a list op copy operations. A copy operation itself has 3 parameters, source
and target
are nbt paths similar to nbt paths used in /data
. op
is the third parameter and can be replace
, append
(for lists) and merge
(for compounds). In vanilla, this function is used for banners, player heads and shulker boxes to keep their nbt data when dropped.
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "Patterns",
"target": "BlockEntityTag.Patterns",
"op": "replace"
}
]
}
The minecraft:apply_bonus
function applies one of predefined bonus formulas. It has 3 parameters, enchantment
: an enchantment id used for level calculation, formula
: type of used bonus formula and parameters
: values required for the formula, which depend on the formula type.
- Parameters:
extra
(int) andprobability
(float) - Random value: binomial distribution with n =
level + extra
and p =probability
- Parameters:
bonusMultiplier
(float) - Random value: uniform distribution from
0
tolevel * bonusMultiplier
- Parameters: none
- Random value: not known
- This loot table will drop a player head of the player that died with the name of the killer in the lore if the player was killed by another player.
{
"type": "minecraft:entity",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:player_head",
"functions": [
{
"function": "minecraft:fill_player_head",
"entity": "this"
},
{
"function": "set_lore",
"lore": [{"text": "Killer: "}, {"selector": "@s"}],
"entity": "killer"
}
],
"conditions": [
{
"condition": "damage_source_properties",
"predicate": {
"source_entity": {
"type": "minecraft:player"
}
}
}
]
}
]
}
]
}
OMG thank you !!