Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Loot context

From SAS Gaming Wiki

Template:Exclusive

A loot context is a set of parameters available to Minecraft:loot tables, Minecraft:predicates, Minecraft:item modifiers, Minecraft:number providers, and Minecraft:slot sources.

When evaluating these data types in different situations, different parameters will be available. For example, a loot table that runs when the player mines a block would get a tool parameter if the player used an item to do it, but a loot table that populates a treasure chest would never get a tool parameter. Loot contexts are Minecraft:identifiers describing which parameters are available in specific situations. If one is set as the Template:Nbt of a loot table, it can be used to check whether the loot table depends on parameters that will never be available in its intended use case, allowing the game to report a problem when the Minecraft:data pack is loaded.

Loot context types and uses

Used for loot tables

These loot context types are used for evaluating Minecraft:loot tables, and other data types when they appear inside of loot tables.

Loot context type When it is used Loot context parameters that are supplied Loot context parameters that may be supplied
Template:Cdanchor
  • Used only by the hardcoded empty loot table. Supplies no loot context parameters.
  • Specifying Template:Cd means no context parameters can be used in this loot table.
None None
Template:Cdanchor
  • Origin: The center of the chest.
Template:Cdanchor
  • Origin: The position of the fishing bobber.
  • Tool: The fishing rod item that the player cast
Template:Cdanchor
  • Loot from a living entity's death.
  • The command Template:Cmd.
  • Template:Cd 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.
  • Template:Cd entity: The entity that was the source of the final damage to the victim entity.
  • Template:Cd entity: The entity that directly contacted the victim entity to kill them.
  • Template:Cd entity: The player that most recently damaged the victim entity.
Template:Cdanchor
  • Origin: The position of the entity being spawned.
  • Template:Cd entity: The entity being spawned.
Template:Cdanchor
  • Origin: The center of the suspicious block.
  • Template:Cd entity: The entity that used the brush on the suspicious block.
  • Tool: The tool used for brushing.
Template:Cdanchor
  • Origin: The center of the vault.
  • Template:Cd entity: The entity that opened the vault. Not present for item display inside vaults.
  • Tool: The item used as a key.
Template:Cdanchor
  • Gift from a cat, villager or sniffer.
  • Item laid by a chicken.
  • Origin: The cat, villager or sniffer's location.
  • Template:Cd entity: The cat, villager or sniffer that gave the gift. / The chicken that laid the item.
Template:Cdanchor 
Template:Cdanchor
  • Template:Cd entity: The player that gained the advancement.
  • Origin: The player's location when they gained the advancement.
Template:Cdanchor
  • Not used. Supplies all loot context parameters.
  • Specifying Template:Cd or omitting it means no checking for context parameters in this loot table when loading the data pack.
N/A N/A
Template:Cdanchor
  • Loot from mining a block.
  • Loot from a block being exploded.
  • The command Template:Cmd.
  • Block state: The block that was broken.
  • Origin: The center of the broken block.
  • Tool: The tool used to mine the block.
  • Template:Cd 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.
Template:Cdanchor
  • Origin: The position of the entity being sheared.
  • Template:Cd entity: The entity being sheared.
  • Tool: The tool used for the interaction.
Template:Cdanchor
  • Template:Cd: The entity being interacted with.
  • Tool: The tool used for the interaction.
Template:Cdanchor
  • Block state: The block that was interacted with.
  • Origin: The center of the block that was interacted with.Template:Upcoming
  • Block entity: Any block entity data of the block that was interacted with, if it is a block entity.
  • Template:Cd: The player or entity that interacted.
  • Tool: The tool used for the interaction.

Not used in loot tables

These loot contexts are not used to evaluate loot tables. Instead, they are used for other invocations of Minecraft:predicates, Minecraft:item modifiers, Minecraft:slot sourcesTemplate:Upcoming, and Minecraft:number providersTemplate:Upcoming.

Loot context type When it is used Loot context parameters that are supplied Loot context parameters that may be supplied
Template:Cdanchor
  • Origin: The position where the command is run.
Template:CdanchorTemplate:Upcoming
  • Origin: The position where the command is run.
Template:CdanchorTemplate:Upcoming
Template:CdanchorTemplate:Upcoming
  • Origin: The position where the command is run.
  • Block state: The current state of the block at the position passed to Template:Command.
Template:CdanchorTemplate:Upcoming
  • Origin: The position where the command is run.
  • Container: The container or inventory being evaluated.
Template:Cdanchor
  • Origin: The position of the entity being checked.
  • Template:Cd entity: The entity being checked.
Template:Cdanchor
  • Used when an advancement invokes a predicate on an entity.
  • Template:Cd entity: The entity being checked.
  • Origin: The position of the player who triggers this advancement criterion.
Template:Cdanchor
  • Used when an advancement invokes a predicate on the location of a block where an item was used on.
  • Template:Cd 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: Template:Upcoming Any block entity data of the block at the location, if it was a block entity.
Template:Cdanchor
  • Used when an advancement invokes a predicate on Template:Cd trigger.
  • Template:Cd 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.
Template:CdanchorTemplate:Upcoming
  • 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.
Template:Cdanchor
  • Template:Cd entity: The attacked entity.
  • Enchantment level: The level of the enchantment currently evaluated
  • Origin: Position of the event Template:More info
  • Damage source: The damage source of the attack that caused the enchantment to trigger
Template:Cdanchor
  • Tool: The item enchanted with the evaluated enchantment.
  • Enchantment level: The level of the enchantment currently evaluated
Template:Cdanchor
  • Template:Cd entity: The attacked entity.
  • Enchantment level: The level of the enchantment currently evaluated
  • Origin: Position of the event Template:More info
  • Enchantment active status: Whether the enchantment was already active before the current evaluation
Template:Cdanchor
  • Template:Cd entity: The attacked entity.
  • Enchantment level: The level of the enchantment currently evaluated
  • Origin: Position of the event Template:More info
Template:Cdanchor
  • Template:Cd 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
Template:Cdanchor Used for evaluating villager trades.
  • Origin: The position of the villager or wandering trader
  • Template:Cd 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 Template:DCL on the item.

Navigation

Template:Navbox Java Edition technical

Minecraft:de:Beutekontext Minecraft:fr:Contexte de butin Minecraft:ja:ルート文脈 Minecraft:pt:Contexto de saque Minecraft:zh:战利品上下文