Loot table

Loot tables are technical JSON files that are used to dictate what items should generate in various situations, such as what items should be in naturally generated containers, what items should drop when breaking a block or killing a mob, what items can be fished, and more. They do not affect dropped experience, or dropped non-item entities such as slimes from larger slimes or silverfish from infested blocks.
== Definition ==
Custom data packs use loot tables to change what loot can spawn in containers or drop by mobs. They can either change existing loot tables or create new ones. Note that some blocks, such as bedrock, end portals and other blocks unbreakable in Survival do not have loot tables, some blocks share loot tables (namely wall and floor variants of blocks) and that certain drops, namely head drops from charged creepers and the wither's nether star, are currently not covered by loot tables.
Loot tables belong in the following folder of a data pack's structure: 
* (data pack name)
** data
*** (namespace)
**** loot_tables (pre-1.21)
**** loot_table (1.21+)
***** (loot_table_name).json
Vanilla loot tables are grouped into 4 categories: (fishing, cat morning gift, piglin bartering), , , and , with some tables being in subfolders of those. For example, the file for zombies would go in data pack name/data/minecraft/loot_tables/entities/zombie.json. This makes every zombie in that world use the datapack's loot table rather than the default zombie loot table.
== Usage ==
The loot tables are structured as a String tag that determines the table to use, and a Long tag determining the seed. Containers or mobs with the same seed and table drop the same items. Loot tables do not determine the container's slot to be used; that is randomly determined based on the seed.
For :
* The root object.
** : Loot table to be used to fill the container when it is next opened, or the items are otherwise interacted with. When the container is a chest that is part of a double chest, only the half corresponding to the tagged single-chest is affected.
** : Seed for generating the loot table. Works similarly to the seeds for worlds. 0 or omitted uses a random seed.
These tags are removed once the items have been interacted with (by opening the container, breaking the container, etc.), and only then are items put in the container.
For mobs:
* The root object.
** : Loot table to be used for the items that drop when the entity is killed.
** : Seed for generating the loot table. Works similarly to the seeds for worlds. 0 or omitted uses a random seed. 
The loot tables of mobs and containers can be altered with and . The player could also grant a loot table to an entity or drop it in the world with .
== Tags ==
Loot tables are defined using the JSON format. Below are a list of tags used.
* The root object.
** : Optional, specifies the context in which the loot table should be invoked. All item functions, predicates and number providers are then validated to ensure the parameters of the context type specified here will cover all requirements, and prints a warning message in the output log if any function or condition requires a context parameter that is not covered. Valid loot context types are described below.
** : Invokes item functions, in order, upon all item stacks generated by this table.
*** An item function. The JSON structure of this object is described on the Item modifiers page.
** : A list of all pools for this loot table. Each pool used generates items from its list of items based on the number of rolls. Pools are applied in order.
*** A pool. The JSON structure of this object is described below.
** : A resource location specifying the name of the random sequence that will be used to generate loot from this loot table. If only one loot table uses a specific random sequence, the order of the randomized sets of items generated is the same for every world using the same world seed. If multiple loot tables use the same random sequence, the loot generated from any one of them changes depending on how many times and in what order any of the other loot tables were invoked.
=== Pool ===
* The root object.
** : A list of predicates that must all pass for this pool to be used.
*** A predicate. The JSON structure of this object is described on the Predicates page.
** : Invokes item functions, in order, to all item stacks generated by this pool.
*** An item function. The JSON structure of this object is described on the Item modifiers page.
** : A Number Provider. Specifies the number of rolls on the pool.
** : A Number Provider. Specifies the number of bonus rolls on the pool per point of luck. Rounded down after multiplying. Defaults to exactly 0.0.
** : A list of all things that provide loot entries for this pool. One loot entry is chosen per roll as a weighted random selection from all loot entries added into the pool. Note that it is not selected weightedly from the elements of this list, instead, the weighted selection is to select from all loot entries provided by these elements (entry providers), which are different because an element (entry provider) can provide empty, or one or more weighted loot entries.
*** The JSON structure of this object is described below.
=== Entry provider ===
* The root object.
** : A list of predicates that must all pass for the provided loot entry/ies to be added into the loot pool.
*** A predicate. The JSON structure of this object is described on the Predicates page.
** : Resource location of the type of entry provider. Set to one of the following values.
The possible values for and associated extra contents:
* item—Provides a loot entry that drops a single item stack.
** : Invokes item functions to the item stack(s).
*** An item function. The JSON structure of this object is described on the Item modifiers page.
** : Determines how often the loot entry is chosen out of all the entries in the pool. Entries with higher weights are used more often. The chance of an entry being chosen is [this entry's weight ÷ total of all considered entries' weights].
** : Modifies the loot entry's based on the luck attribute of the for loot context type or the entity for all other loot table types. Formula is .
** : The resource location of the item to be generated, e.g. . The default, if not changed by item functions, is a stack of 1 of the default instance of the item.
* tag—Provides a loot entry that generates all item in an item tag, or multiple loot entries (each entry generates a single item in the item tag).
** : Invokes item functions to the item stack(s).
*** An item function. The JSON structure of this object is described on the Item modifiers page.
** : Determines how often a loot entry is chosen out of all the entries in the pool. Entries with higher weights are used more often. The chance of an entry being chosen is [this entry's weight ÷ total of all considered entries' weights].
** : Modifies the loot entry's based on the luck attribute of the for loot context type or the entity for all other loot table types. Formula is .
** : The resource location of the item tag to query, e.g. .
** : If set to , provides one loot entry per item in the tag with the same weight and quality, and each entry generates one item. If , provides a single loot entry that generates all items (each with count of 1) in the tag.
* loot_table—Provides another loot table as a loot entry.
** : Invokes item functions to the item stack(s).
*** An item function. The JSON structure of this object is described on the Item modifiers page.
** : Determines how often the loot entry is chosen out of all the entries in the pool. Entries with higher weights are used more often. The chance of an entry being chosen is [this entry's weight ÷ total of all considered entries' weights].
** : Modifies the loot entry's based on the luck attribute of the for loot context type or the entity for all other loot table types. Formula is .
** : The resource location of the loot table to be used, e.g. .
* dynamic—Provides a loot entry that generates block-specific drops.
** : Invokes item functions to the item stack(s).
*** An item function. The JSON structure of this object is described on the Item modifiers page.
** : Determines how often the loot entry is chosen out of all the entries in the pool. Entries with higher weights are used more often. The chance of an entry being chosen is [this entry's weight ÷ total of all considered entries' weights].
** : Modifies the loot entry's based on the luck attribute of the for loot context type or the entity for all other loot table types. Formula is .
** : Can be contents to drop block entity contents.
* empty—Provides a loot entry that generates nothing into the loot pool.
** : Invokes item functions to the item stack(s).
*** An item function. The JSON structure of this object is described on the Item modifiers page.
** : Determines how often the loot entry is chosen out of all the entries in the pool. Entries with higher weights are used more often. The chance of an entry being chosen is [this entry's weight ÷ total of all considered entries' weights].
** : Modifies the loot entry's based on the luck attribute of the for loot context type or the entity for all other loot table types. Formula is .
* group—All entry providers in the children list is applied into the loot pool. Can be used for convenience, e.g. if one condition applies for multiple entries.
** : The list of entry providers.
*** An entry provider. 
* alternatives—Only the first successful (conditions are met) entry provider, in order, is applied to the loot pool.
** : The list of entry providers.
*** An entry provider.
* sequence—The child entry providers are applied to the loot pool in sequential order, continuing until an entry provider's conditions are not met, then applying no more entry providers from the children.
** : The list of entry providers.
*** An entry provider.
== Recurring JSON structures within loot tables and other data pack files ==
=== Predicate ===
Predicates (aka. Loot conditions) are JSON structures that are used within loot tables to add requirements to a drop, pool, or function. They can also be used in standalone files (see Predicate), where they can be called upon from multiple different contexts.
The specific structure of a predicate is shown on the Predicates page.
=== Item function ===
Item functions (aka. loot functions) are used within loot tables to apply modifications to the item stack being generated, such as adjusting the stack size or adding enchantments. They can also be used in standalone files called Item modifiers, where they can be called upon to modify items in an already existing item slot within a block or entity's inventory.
The specific structure of an item function is shown on the Item modifiers page.
=== Number Providers ===
Loot tables use number providers in some places that accept an int or float. They can either be defined as a constant value or as an object.
* : Constant number provider.
Or:
* : The root tag.
** : The number provider type.
The possible values for and associated extra contents:
* constant—A constant value.
** : The exact value.
* uniform—A random number following a uniform distribution between two values (inclusive).
** : Number provider. The minimum value.
** : Number provider. The maximum value.
* binomial—A random number following a binomial distribution
** : Number provider. The amount of trials.
** : Number provider. The probability of success on an individual trial.
* score—To query and use a scoreboard value.
** : To choose which player name or entity UUID to query.
*** : Set to to manually specify a player name or UUID. Set to to use an entity from loot context.
*** : Included only if is set to . Specifies the name of the player, or the entity's UUID (in hypenated hexadecimal format) whose score to query.
*** : Included only if is set to . Specifies an entity from loot context to query the score of. Can be , , , or .
** : The scoreboard objective to query on the selected player name or UUID.
** : Optional. Scale to multiply the score before returning it.
== Loot context types ==
The field is used when loading the data pack to check whether the context parameters used by this loot table match the specified context type. The field makes it possible to check for errors in the loot table files without applying them in-game. If the loot table is used for a specific context, specifying the type field allows the game to check whether the loot table file uses parameters that will not be provided in that context.
Depending on the type of invocation, different parameters may be supplied to predicates, loot functions and number providers. Below is a list of all possible contexts of invocation, and the parameters:
Loot context type	When it is used	Loot context parameters that are supplied	Loot context parameters that may be supplied
 	
* Only used by the hardcoded empty loot table. Supplies no loot context parameters. 
* Specifying means no context parameters can be used in this loot table.	None 	None
 	
* Opening of a container with loot table (can be ).
* The command .	
* Origin: The center of the chest. 	
* entity: The entity that opened the chest.
 	
* Not used for loot tables. Specifying doesn't make sense.
* Used internally by commands such as or .	
* Origin: The position where the command is run.	
* entity: The entity that is when the command is run.
 	
* Not used for loot tables. Specifying doesn't make sense.
* Used internally by the target selector argument.	
* Origin: The position of the entity being checked.
* entity: The entity being checked.	
 	
* Fishing.
* The command .	
* Origin: The position of the fishing bobber.
* Tool: The fishing rod item that the player cast	
* entity: The fishing bobber.
 	
* Loot from a living entity's death.
* The command .	
* entity: The entity that died.
* Origin: The location of the entity's death.
* Damage source: The source of the damage that caused the entity to die.	
* entity: The entity that was the source of the final damage to the victim entity.
* entity: The entity that directly contacted the victim entity to kill them.
* entity: The player that most recently damaged the victim entity.
 	
* Using a brush on suspicious sand that has a loot table.	
* Origin: The center of the suspicious sand.	
* entity: The entity that used the brush on the suspicious sand.
 	
* Gift from a cat or villager.	
* Origin: The cat or villager's location.
* entity: The cat or villager that gave the gift.	
  	
* Bartering with piglins.	
* entity: The piglin bartered with. 	
 	
* Loot table set as an advancement's reward.	
* entity: The player that gained the advancement.
* Origin: The player's location when they gained the advancement.	
 	
* Not used for loot tables. Specifying doesn't make sense.
* Used internally when an advancement invokes a predicate on an entity.	
* entity: The entity being checked.
* Origin: The position of the player who triggers this advancement criterion.	
 	
* Not used for loot tables. Specifying doesn't make sense.
* Used internally when an advancement invokes a predicate on the location of a block which an item was used on.	
* entity: The player to gain the advancement.
* Origin: The center of the block that was interacted with.
* Tool: The item used to interact with the block.
* Block state: The block that was interacted with.	
 	
* Not used. Supplies all loot context parameters.
* Specifying or omitting it means no checking for context parameters in this loot table when loading the data pack.	N/A 	N/A
 	
* Loots from breaking a block.
* The command .	
* Block state: The block that was broken.
* Origin: The center of the broken block.
* Tool: The tool used to mine the block.	
* entity: The player that mined the block.
* Block entity: Any block entity data of the block that was broken, if it was a block entity.
* Explosion radius: The radius of the explosion that broke the block, if broken via an explosion.
== History ==
==Issues==
==References==
de:Beutetabellen
fr:Table de butin
ja:ルートテーブル
ko:노획물 목록
nl:Buittabel
pl:Tabela łupów
pt:Tabela de itens
ru:Таблицы добычи
zh:战利品表