Minecraft Wiki
Advertisement
For predicates inside models, see Item predicate.
Information icon.svg
This feature is exclusive to Java Edition. 

Predicates are data pack files that contain loot conditions. Loot conditions, when invoked, either pass or fail based on whether their criteria is met, returning their result to the invoker. Standalone predicate files can be invoked by /execute if predicate, the predicate target selector argument, or from loot conditions within other files.

Inside a data pack, predicate files are located within data/<namespace>/predicates.

JSON format[]

Predicates are defined using the JSON format. The root tag can be either an  object or an  array:

  • The root tag, if including multiple conditions within the predicate. All conditions must pass for the predicate to pass.
    • A condition in this predicate. Can also be the root tag if only entering a single condition.
      •  condition: The condition's resource location.
      • Other parts of the condition, specified below.

The possible values for  condition and associated extra contents:

  • alternative—Evaluates a list of predicates and succeeds only if at least one of them succeeds. Invokable from any context.
    •  terms: The list of predicates to evaluate. Predicates within this array must be  objects, they cannot themselves be arrays.
      • A predicate.
  • block_state_property—Checks the mined block and its block states. Invokable from loot tables, and always fails when invoked from anything else.
    •  block: A block ID. The test fails if the block doesn't match.
    •  properties: (Optional) A map of block property names to values. All values are strings. The test fails if the block doesn't match.
  • damage_source_properties—Checks properties of damage source. Invokable from advancements or loot tables, and fails when invoked from anything else.
    •  predicate: Predicate applied to the damage source.
      • Tags common to all damage types
  • entity_properties—Checks properties of an entity. Invokable from any context.
    •  entity: The entity to check. Set to this to use the entity that invoked this condition, killer for the killer of the this entity, or killer_player to only select the killer if they are a player.
    •  predicate: Predicate applied to entity, uses same structure as advancements.
      • All possible conditions for entities
  • entity_scores—Checks the scoreboard scores of an entity. May be invoked from any context.
    •  entity: The entity to check. Set to this to use the entity that invoked this condition, killer for the killer of the this entity, or killer_player to only select the killer if they are a player.
    •  scores: Scores to check. All specified scores must pass for the condition to pass.
      •  A score: Key name is the objective while the value specifies a range of score values required for the condition to pass.
      •  A score: Shorthand version of the other syntax above, to check the score against a single number only. Key name is the objective while the value is the required score.
  • inverted—Inverts another loot table condition. Invokable from any context.
    •  term: The condition to be negated, following the same structure as outlined here, recursively.
  • killed_by_player—Checks if a killer_player entity exists. Invokable from advancements or loot tables, and fails when invoked from anything else.
    •  inverse: If true, the condition passes if killer_player is not available.
  • location_check—Checks the current location against location criteria. Invokable from any context.
    •  offsetX - optional offsets to location
    •  offsetY - optional offsets to location
    •  offsetZ - optional offsets to location
    •  predicate: Predicate applied to location, uses same structure as advancements.
      • Tags common to all locations
  • match_tool—Checks tool used to mine the block. Invokable from loot tables, and fails when invoked from anything else.
    •  predicate: Predicate applied to item, uses same structure as advancements.
      • Tags common to all items
  • random_chance—Generates a random number between 0.0 and 1.0, and checks if it is less than a specified value. Invokable from any context.
    •  chance: Success rate as a number 0.0–1.0.
  • random_chance_with_looting—Generates a random number between 0.0 and 1.0, and checks if it is less than a specified value which has been affected by the level of Looting on the killer entity. Invokable from advancements and loot tables, and fails[verify] when invoked from anything else.
    •  chance: Base success rate.
    •  looting_multiplier: Looting adjustment to the base success rate. Formula is chance + (looting_level * looting_multiplier).
  • reference—Invokes a predicate file and returns its result. Invokable from any context.
    •  name: The resource location of the predicate to invoke. A cyclic reference causes a parsing failure.
  • survives_explosion—Returns true with 1 ÷ explosion radius probability. Invokable only from loot tables, and fails[verify] when invoked from anything else.
  • table_bonus—Passes with probability picked from table, indexed by enchantment level.
    •  enchantment: Id of enchantment.
    •  chances: List of probabilities for enchantment level, indexed from 0.
  • time_check—Compares the current game time (the age of the world in game ticks) against given values. Invokable from any context.
    •  value: The time to compare the game time against.
    •  value: Shorthand version of  value above, used to check for a single value only. Number providers cannot be used in this shorthand form.
    •  period: If present, the game time is first reduced modulo the given number before being checked against  value. For example, setting this to 24000 causes the checked time to be equal to the current daytime.
  • value_check—Compares a number against another number or range of numbers. Invokable from any context.
    •  value: Number Provider. The number to test.
    •  range: The range of numbers to compare  value against.
    •  range: Shorthand version of  range above, used to compare  value against a single number only. Number providers cannot be used in this shorthand form.
  • weather_check—Checks the current game weather. Invokable from any context.
    •  raining: If true, the condition evaluates to true only if it's raining or thundering.
    •  thundering: If true, the condition evaluates to true only if it's thundering.

History[]

Java Edition
1.1519w38aAdded predicates to data packs.
Advertisement