This feature is exclusive to Java Edition.
 

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 Edit

Uses in loot tables Edit

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
  • 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.
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.
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.

Only used in predicates Edit

These loot contexts cannot be set at type of a loot table. Instead, they are used for other invocation of predicates and item modifiers.

Loot context type When it is used Loot context parameters that are supplied Loot context parameters that may be supplied
command
  • Used internally by commands such as /item modify or /execute (if|unless) predicate.
  • Origin: The position where the command is run.
  • 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_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.
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: Weather 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

Navigation Edit