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: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: updated from Minecraft
SyncBot (talk | contribs)
Sync: updated from Minecraft
Line 148: Line 148:
|-
|-
| {{cd|command}} ||
| {{cd|command}} ||
* Used internally to evaluate [[Minecraft:predicate]]s and [[Minecraft:item modifier]]s by commands such as {{cmd|item modify}} or {{cmd|execute (if{{!}}unless) predicate}}.
* Used to evaluate [[Minecraft:predicate]]s and [[Minecraft:item modifier]]s by commands such as {{cmd|item modify}} or {{cmd|execute (if{{!}}unless) predicate}}.
|  
|  
* '''Origin:''' The position where the command is run.
* '''Origin:''' The position where the command is run.
|
|
* '''{{cd|this}} entity:''' The entity that is {{cd|@s}} when the command is run.
* '''{{cd|this}} entity:''' The entity that is {{cd|@s}} when the command is run.
|-
| {{cd|command_compute_default}}{{upcoming|java 26.3}} ||
* Used to evaluate [[Minecraft:number provider]]s by {{command|compute default}}.
|
* '''Origin:''' The position where the command is run.
|
* '''{{cd|this}} entity:''' The entity that is {{cd|@s}} when the command is run.
|-
| {{cd|command_compute_entity}}{{upcoming|java 26.3}} ||
* Used to evaluate [[Minecraft:number provider]]s by {{command|compute entity}}.
|
* '''Origin:''' The position where the command is run.
* '''{{cd|target_entity}}:''' The entity passed to {{command|compute entity}}.
|
* '''{{cd|this}} entity:''' The entity that is {{cd|@s}} when the command is run.
|-
| {{cd|command_compute_position}}{{upcoming|java 26.3}} ||
* Used to evaluate [[Minecraft:number provider]]s by {{command|compute block}}.
|
* '''Origin:''' The position where the command is run.
* '''Block state:''' The current state of the block at the position passed to {{command|compute block}}.
|
* '''{{cd|this}} entity:''' The entity that is {{cd|@s}} when the command is run.
* '''Block entity:''' The block entity of the block passed to {{command|compute block}}, if it was a block entity.
|-
|-
| {{cd|command_slot_source}}{{upcoming|java 26.3}} ||
| {{cd|command_slot_source}}{{upcoming|java 26.3}} ||
* Used internally to evaluate [[Minecraft:slot sources]] by commands such as {{cmd|item}} or {{cmd|execute (if{{!}}unless) item}}.
* Used to evaluate [[Minecraft:slot sources]] by commands such as {{cmd|item}} or {{cmd|execute (if{{!}}unless) item}}.
|  
|  
* '''Origin:''' The position where the command is run.
* '''Origin:''' The position where the command is run.
Line 163: Line 187:
|-
|-
| {{cd|selector}} ||
| {{cd|selector}} ||
* Used internally by the {{cd|predicate}} [[Minecraft:Target selectors|target selector]] argument.
* Used by the {{cd|predicate}} [[Minecraft:Target selectors|target selector]] argument.
|
|
* '''Origin:''' The position of the entity being checked.
* '''Origin:''' The position of the entity being checked.
Line 170: Line 194:
|-
|-
| {{cd|advancement_entity}} ||
| {{cd|advancement_entity}} ||
* Used internally when an advancement invokes a predicate on an entity.
* Used when an advancement invokes a predicate on an entity.
|
|
* '''{{cd|this}} entity:''' The entity being checked.
* '''{{cd|this}} entity:''' The entity being checked.
Line 177: Line 201:
|-
|-
| {{cd|advancement_location}}||
| {{cd|advancement_location}}||
* Used internally when an advancement invokes a predicate on the location of a block where an item was used on.
* Used when an advancement invokes a predicate on the location of a block where an item was used on.
|
|
* '''{{cd|this}} entity:''' The player to gain the advancement.
* '''{{cd|this}} entity:''' The player to gain the advancement.
Line 187: Line 211:
|-
|-
| {{cd|block_use}}||
| {{cd|block_use}}||
* Used internally when an advancement invokes a predicate on {{cd|default_block_use}} trigger.
* Used when an advancement invokes a predicate on {{cd|default_block_use}} trigger.
|
|
* '''{{cd|this}} entity:''' The player to gain the advancement.
* '''{{cd|this}} entity:''' The player to gain the advancement.
Line 195: Line 219:
|-
|-
| {{cd|container_process}}{{upcoming|java 26.3}} ||
| {{cd|container_process}}{{upcoming|java 26.3}} ||
* Used internally by [[Minecraft:smelting]] blocks and [[Minecraft:brewing stand]]s to evaluate [[Minecraft:Data component format#cooking_fuel|{{cd|cooking_fuel}}]] and [[Minecraft:Data component format#brewing_fuel|{{cd|brewing_fuel}}]] respectively.
* Used by [[Minecraft:smelting]] blocks and [[Minecraft:brewing stand]]s to evaluate [[Minecraft:Data component format#cooking_fuel|{{cd|cooking_fuel}}]] and [[Minecraft:Data component format#brewing_fuel|{{cd|brewing_fuel}}]] respectively.
|
|
* '''Origin:''' The center of the workstation block.
* '''Origin:''' The center of the workstation block.

Revision as of 11:15, 26 August 2026

Template:Exclusive

A loot context is a set of parameters available to Minecraft:loot tables, Minecraft:predicates, Minecraft:item modifiers, and Minecraft: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 Minecraft:loot tables and can be set as the Template:Nbt of a loot table.

Loot context type When it is used Loot context parameters that are supplied Loot context parameters that may be supplied
Template:Cd
  • 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:Cd
  • Origin: The center of the chest.
Template:Cd
  • Origin: The position of the fishing bobber.
  • Tool: The fishing rod item that the player cast
Template:Cd
  • 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:Cd
  • Origin: The position of the entity being spawned.
  • Template:Cd entity: The entity being spawned.
Template:Cd
  • 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:Cd
  • 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:Cd
  • 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:Cd 
Template:Cd
  • Template:Cd entity: The player that gained the advancement.
  • Origin: The player's location when they gained the advancement.
Template:Cd
  • 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:Cd
  • 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:Cd
  • Origin: The position of the entity being sheared.
  • Template:Cd entity: The entity being sheared.
  • Tool: The tool used for the interaction.
Template:Cd
  • Template:Cd: The entity being interacted with.
  • Tool: The tool used for the interaction.
Template:Cd
  • 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.

Only used in predicates

These loot contexts cannot be set at type of a loot table. Instead, they are used for other invocation 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:Cd
  • Origin: The position where the command is run.
Template:CdTemplate:Upcoming
  • Origin: The position where the command is run.
Template:CdTemplate:Upcoming
Template:CdTemplate: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:CdTemplate:Upcoming
  • Origin: The position where the command is run.
  • Container: The container or inventory being evaluated.
Template:Cd
  • Origin: The position of the entity being checked.
  • Template:Cd entity: The entity being checked.
Template:Cd
  • 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:Cd
  • 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:Cd
  • 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:CdTemplate: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:Cd
  • 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:Cd
  • Tool: The item enchanted with the evaluated enchantment.
  • Enchantment level: The level of the enchantment currently evaluated
Template:Cd
  • 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:Cd
  • Template:Cd entity: The attacked entity.
  • Enchantment level: The level of the enchantment currently evaluated
  • Origin: Position of the event Template:More info
Template:Cd
  • 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:Cd 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:战利品上下文