Loot table

From Minecraft Wiki
Jump to: navigation, search

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. It does not affect dropped experience, or dropped non-item entities such as slimes from larger slimes or silverfish from infested blocks.

Usage[edit]

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 chests, trapped chests, hoppers, storage minecarts, minecarts with hoppers, dispensers, droppers, shulker boxes and barrels:

    •  LootTable: 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.
    •  LootTableSeed: 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 tag.
    •  DeathLootTable: Loot table to be used for the items that drop when the entity is killed.
    •  DeathLootTableSeed: 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 /execute store and /data merge. The player could also grant a loot table to an entity or drop it in the world with /loot.

Tags[edit]

Loot tables are defined using the JSON format. Below are a list of tags used.

  •  The root tag
    •  type: Optional type of the loot table. Must be one of empty if the loot table does not generate any loot, entity for loot an entity drops, block for loot a block drops, chest for a treasure chest, fishing for a fishing loot table, gift for a cat or villager gift, advancement_reward if it's used as a reward for an advancement, barter for loot from bartering with piglins, command for /execute, selector for predicate= in selectors, advancement_entity for entity predicates in advancements or generic if none of the above apply.
    •  functions: Applies functions to all item stacks produced by this table. Functions are applied in order, so for example looting_enchant must be after set_count to work correctly.
      • A function.
        •  function: Namespaced ID of the function to apply. Valid functions are described below.
        •  conditions: Determines conditions for this function to be applied. If multiple conditions are specified, all must pass.
          • A condition.
    •  pools: 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.
        •  conditions: Determines conditions for this pool to be used. If multiple conditions are specified, all must pass.
          • A condition.
        •  functions: Applies functions to all item stacks produced by this pool. Functions are applied in order, so for example looting_enchant must be after set_count to work correctly.
          • A function.
            •  function: Namespaced ID of the function to apply. Valid functions are described below.
            •  conditions: Determines conditions for this function to be applied. If multiple conditions are specified, all must pass.
              • A condition.
        •  rolls: Number Provider. Specifies the number of rolls on the pool.
        •  bonus_rolls: Number Provider. Specifies the number of bonus rolls on the pool per point of luck. Rounded down after multiplying.
        •  entries: A list of all things that can be produced by this pool. One entry is chosen per roll as a weighted random selection from all entries without failing conditions.
          • An entry.
            •  conditions: Determines conditions for this entry to be used. If multiple conditions are specified, all must pass.
              • A condition.
            •  functions: Applies functions to the item stack or item stacks being produced. Functions are applied in order, so for example looting_enchant must be after set_count to work correctly.
              • A function.
                •  function: Namespaced ID of the function to apply. Valid functions are described below.
                •  conditions: Determines conditions for this function to be applied. If multiple conditions are specified, all must pass.
                  • A condition.
            •  type: Namespaced ID type of entry. Can be item for item entries, tag for item tags, loot_table to produce items from another loot table, group for child entries, alternatives to select one sub-entry from a list, sequence to select sub-entries until one entry cannot be granted, dynamic to generate block specific drops, or empty for an entry that generates nothing.
            •  name:
              • For type 'item', ID name of the item to be produced, e.g. diamond. The default, if not changed by functions, is a stack of 1 of the default instance of the item.
              • For type 'tag' item tag to be used, e.g. arrows.
              • For type 'loot_table', loot table to be used, e.g. gameplay/fishing/junk.
              • For type 'dynamic', can be contents for block entity contents or self for banners and player skulls.
            •  children:
              • For type 'group' a list of entries that are used to generate loot. Can be used for convenience, e.g. if one condition applies for multiple entries.
              • For type 'alternatives' a list of entries of which the first, and only the first, successful entry gets generated.
              • For type 'sequence' a list of entries that are used until the first entry fails. After an entry fails, no more entries of this list are generated
            •  expand: For type 'tag', if set to true, it chooses one item of the tag, each with the same weight and quality. If false, it generates one of each of the items in the tag. Required when type is 'tag'.
            •  weight: Determines how often this entry is chosen out of all the entries in the pool. Entries with higher weights are used more often (chance is this entry's weighttotal of all considered entries' weights).
            •  quality: Modifies the entry's weight based on the killing/opening/fishing player's luck attribute. Formula is floor( weight + (quality * generic.luck)).

Functions[edit]

Main article: Item modifier

Loot tables use various functions to change the item stack being produced, such as adjusting the stack size or adding enchantments. Below are a list of valid functions, and the tags used by them. The tags are placed in the same function object as  function:.

The functions from item_modifiers directory in the <namespace> directory in data packs have the same structure as the loot functions. ‌[upcoming: JE 1.17]

See item modifier for the possible functions.

Conditions[edit]

Main article: Predicate

Loot tables use various conditions that add requirements to a drop, pool, or function. Below are a list of valid conditions, and the tags used by them. The tags are placed in the same condition object as  condition.

Moreover, the conditions from predicates directory in the <namespace> directory in data packs have the same structure as the loot conditions.

See predicate for the possible conditions.

Number Providers[edit]

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.
  • : The root tag.
    •  type: The number provider type.

The possible values for  type and associated extra contents:

  • constant - A constant value.
    •  value: The exact value
  • uniform - A random number following a uniform distribution between two values (inclusive).
    •  min: Number provider. The minimum value.
    •  max: Number provider. The maximum value.
  • binomial - A random number following a binomial distribution
    •  n: Number provider. The amount of trials.
    •  p: Number provider. The probability of success on an individual trial.
  • score[upcoming: JE 1.17] - A scoreboard value
    •  target: Scoreboard name provider. One of this, killer, direct_killer, player_killer.
    •  target: Scoreboard name provider
      •  type: Resource location. Either fixed or context.
      • If type is fixed:
        •  name: A UUID or playername.
      • If type is context:
        •  target: Scoreboard name provider. One of this, killer, direct_killer, player_killer.
    •  score: The scoreboard objective.
    •  scale: Optional. Scale to multiply the score before returning it.

List of loot tables[edit]

Below is a list of all loot tables that exist by default. More tables can be added in the world save for use with custom maps. 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.[1]

Data packs[edit]

Main article: data packs

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. This is the file structure:

  • world save folder
    • datapacks
      • data pack

The JSON files go in this folder. Vanilla loot tables are grouped into 4 categories: gameplay (fishing), entities, blocks, and chests, with some tables being in subfolders of those. For example, the file for zombies would go in datapacks/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.

Loot tables are namespaced. To create a custom loot table, first create a new folder for the custom namespace, and then create loot tables within following a similar structure. Then, summon the mob with the data tag DeathLootTable set to the name of the directory and file (without the .json extension), such as DeathLootTable:"custom_namespace:path/to/table".

History[edit]

Java Edition
1.9October 19, 2015Dinnerbone announces loot tables.
15w43aAdded loot tables.
15w43bAdded condition entity_scores.
15w43cRenamed "villager_golem.json" to "iron_golem.json"
Added fishing loot tables, sheep without wool, and zombie and skeleton horses.
Renamed the tag  item: to  name:, and the tag  items: to  entries:
Added the tag  type: and support to load a loot table instead of an item.
Added the tag  luck: to default files, though it currently does nothing in the code.
Added the function set_damage.
15w44aAdded the function enchant_randomly and set_attributes.
15w44bAdded the  quality tag.
Removed  luck and  luck_multiplier tags.
Added the  bonus_rolls tag.
15w51aA player in spectator mode no longer triggers a container to use its loot table to generate loot.
1.9.1pre1Loot tables now work with dispensers and droppers.
Added default table chests/jungle_temple_dispenser.
1.1116w32aDonkeys, mules, husks and zombie villagers now each draw from their own loot tables, rather than drawing from the horse and zombie loot tables, respectively
16w43aVillagers, vexes and ender dragons are now able to draw from their own loot tables.
1.1317w43aCustom loot tables have been moved into data packs.
1.1418w43aBlock drops have been changed to use loot tables too.
Loot tables received a bunch of new options.
Setting entity to "this" now refers to the player in chest and block loot tables.
18w44aAdded loot tables for cats, cat_morning_gift, players and withers.
Added loot tables for new blocks.
18w46aAdded loot table for illusioners.
18w48aAdded more loot tables for villages, some of which are currently unused.
Removed loot table: village_blacksmith.
18w49avillage_savanna_house and village_snowy_house loot tables are now used.
Added more loot tables for villages.
18w50avillage_desert_house and village_taiga_house loot tables are now used, making all previously unused loot tables no longer unused.
?Empty loot table is now hardcoded.
1.1519w34aAdded the function copy_state.
1.1620w12aAdded fishing_hook sub-predicate to check properties of the fishing hook.

Issues[edit]

Issues relating to "Loot table" are maintained on the bug tracker. Report issues there.

References[edit]