Home › Loot context
Loot context
Minecraft Wiki article. Categories: Java_Edition, Upcoming, Java_Edition_upcoming_tag, Information_needed, Java_Edition_technical, Data_packs
A loot context is a set of parameters available to loot tables , predicates , item modifiers , and number providers . As different uses have different available parameters, a loot context is used to determine if a given loot table or predicate is valid to that use case, allowing this check to be done when the data pack is loaded, rather than at runtime.
Loot context types and uses
Used in loot tables
These loot context types are used in loot tables and can be set as the [String] type of a loot table.
Loot context type
When it is used
Loot context parameters that are supplied
Loot context parameters that may be supplied
empty
Used only by the hardcoded empty loot table. Supplies no loot context parameters.
Specifying "type":"empty" means no context parameters can be used in this loot table.
None
None
chest
Opening of a container with loot table (can be barrel , chest , trapped chest , hopper , minecart with chest , boat with chest , minecart with hopper , dispenser , dropper , shulker box , dyed shulker box , and decorated pot ).
The command /loot … loot <loot_table> .
Origin: The center of the chest.
this entity: The entity that opened the chest.
fishing
Origin: The position of the fishing bobber.
Tool: The fishing rod item that the player cast
this entity: The fishing bobber.
entity
Loot from a living entity's death.
The command /loot … kill <target> .
this 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.
attacker entity: The entity that was the source of the final damage to the victim entity.
direct_attacker entity: The entity that directly contacted the victim entity to kill them.
attacking_player entity: The player that most recently damaged the victim entity.
equipment
Origin: The position of the entity being spawned.
this entity: The entity being spawned.
archaeology
Origin: The center of the suspicious block.
this entity: The entity that used the brush on the suspicious block.
Tool: The tool used for brushing.
vault
Display of items inside of a vault .
Opening of a vault .
Origin: The center of the vault.
this entity: The entity that opened the vault. Not present for item display inside vaults.
Tool: The item used as a key.
gift
Gift from a cat, villager or sniffer.
Item laid by a chicken.
Origin: The cat, villager or sniffer's location.
this entity: The cat, villager or sniffer that gave the gift. / The chicken that laid the item.
barter
this entity: The piglin bartered with.
advancement_reward
this entity: The player that gained the advancement.
Origin: The player's location when they gained the advancement.
generic
Not used. Supplies all loot context parameters.
Specifying "type":"generic" or omitting it means no checking for context parameters in this loot table when loading the data pack.
N/A
N/A
block
Loot from mining a block.
Loot from a block being exploded.
The command /loot … mine <pos> .
Block state: The block that was broken.
Origin: The center of the broken block.
Tool: The tool used to mine the block.
this entity: The player that mined the block, or the entity that caused the explosion.
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.
shearing
Origin: The position of the entity being sheared.
this entity: The entity being sheared.
Tool: The tool used for the interaction.
entity_interact
target_entity: The entity being interacted with.
Tool: The tool used for the interaction.
interacting_entity: The player or entity that interacted.
block_interact
Block state: The block that was interacted with.
Origin: The center of the block that was interacted with.[upcoming: JE 26.3 ]
Block entity: Any block entity data of the block that was interacted with, if it is a block entity.
interacting_entity: The player or entity that interacted.
Tool: The tool used for the interaction.
Only used in predicates
These loot contexts cannot be set at type of a loot table. Instead, they are used for other invocation of predicates , item modifiers , slot sources [upcoming: JE 26.3 ] , and number providers [upcoming: JE 26.3 ] .
Loot context type
When it is used
Loot context parameters that are supplied
Loot context parameters that may be supplied
command
Origin: The position where the command is run.
this entity: The entity that is @s when the command is run.
command_slot_source[upcoming: JE 26.3 ]
Origin: The position where the command is run.
Container: The container or inventory being evaluated.
this entity: The entity that is @s when the command is run.
selector
Origin: The position of the entity being checked.
this entity: The entity being checked.
advancement_entity
Used internally when an advancement invokes a predicate on an entity.
this entity: The entity being checked.
Origin: The position of the player who triggers this advancement criterion.
advancement_location
Used internally when an advancement invokes a predicate on the location of a block where an item was used on.
this 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.
Block entity: [upcoming: JE 26.3 ] Any block entity data of the block at the location, if it was a block entity.
block_use
Used internally when an advancement invokes a predicate on default_block_use trigger.
this entity: The player to gain the advancement.
Origin: The center of the block that was interacted with.
Block state: The block that was interacted with.
container_process[upcoming: JE 26.3 ]
Origin: The center of the workstation block.
Block state: The state of the workstation block.
Block entity: The block entity data of the workstation block.
Container: The inventory of the workstation block.
enchanted_damage
this entity: The attacked entity.
Enchantment level : The level of the enchantment currently evaluated
Origin : Position of the event [more information needed ]
Damage source : The damage source of the attack that caused the enchantment to trigger
attacker entity: The attacking entity.
direct_attacker entity: The projectile entity used in the attack.
enchanted_item
Tool: The item enchanted with the evaluated enchantment.
Enchantment level : The level of the enchantment currently evaluated
enchanted_location
this entity: The attacked entity.
Enchantment level : The level of the enchantment currently evaluated
Origin : Position of the event [more information needed ]
Enchantment active status : Whether the enchantment was already active before the current evaluation
enchanted_entity
this entity: The attacked entity.
Enchantment level : The level of the enchantment currently evaluated
Origin : Position of the event [more information needed ]
hit_block
this entity: The entity that hit the block.
Enchantment level : The level of the enchantment currently evaluated
Origin : Center of the block that was hit
Block state : The block that was hit
villager_trade
Used for evaluating villager trades .
Origin : The position of the villager or wandering trader
this entity: The villager or wandering trader.
Additional cost component allowed : Unit context. When present, causes the item modifier enchant_with_levels to generate the component additional_trade_cost on the item.
Navigation
Sources