Predicate

Predicates are data pack files that contain predicate conditions. Predicate 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, the target selector argument, or from predicate conditions within other files.

Inside a data pack, predicate files are located within.

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


 * 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.
 * : The condition's resource location.
 * Other parts of the condition, specified below.

The possible values for and associated extra contents:


 * alternative&mdash;Checks other conditions and combines their results using logical disjunction (OR gate). Invokable from  any context .
 * : The list of conditions to check and combine. Conditions within this array must be, they cannot themselves be arrays.
 * A condition, following the structure outlined here, recursively.


 * block_state_property&mdash;Checks the mined block and its block states. Invokable from  loot tables , and always  fails  when invoked from anything else.
 * : A block ID. The test fails if the block doesn't match.
 * : (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&mdash;Check properties of damage source. Invokable from  advancements  or  loot tables , and  fails  when invoked from anything else.
 * : Predicate applied to the damage source.


 * killed_by_player&mdash;Check if a  entity exists. Invokable from  advancements  or  loot tables , and  fails  when invoked from anything else.
 * : If true, the condition passes if  is not available.


 * entity_properties&mdash;Check the specified properties of an entity against criteria. Invokable from  any context .
 * : The entity to check. Set to  to use the entity that invoked this condition,   for the killer of the   entity, or   to only select the killer if they are a player.
 * : Predicate applied to entity, uses same structure as advancements.


 * entity_scores&mdash;Check the scoreboard scores of an entity. May be invoked from  any context .
 * : The entity to check. Set to  to use the entity that invoked this condition,   for the killer of the   entity, or   to only select the killer if they are a player.
 * : Scores to check. All specified scores must pass for the condition to pass.
 * : Key name is the objective while the value specifies a range of score values required for the condition to pass.
 * : Number Provider. Minimum score.
 * : Number Provider. Maximum 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&mdash;Invert another loot table condition. Invokable from  any context .
 * : The condition to be negated, following the same structure as outlined here, recursively.


 * location_check&mdash;Check the current location against location criteria. Invokable from  any context .
 * - optional offsets to location
 * - optional offsets to location
 * - optional offsets to location
 * : Predicate applied to location, uses same structure as advancements.


 * match_tool&mdash;Checks tool used to mine the block. Invokable from  loot tables , and  fails  when invoked from anything else.
 * : Predicate applied to item, uses same structure as advancements.


 * random_chance&mdash;Generate a random number between 0.0 and 1.0, and check if it is less than a specified value. Invokable from  any context .
 * : Success rate as a number 0.0–1.0.


 * random_chance_with_looting&mdash;Generate a random number between 0.0 and 1.0, and check if it is less than a specified value which has been affected by the level of Looting on the  entity. Invokable from  advancements  and  loot tables , and  fails  when invoked from anything else.
 * : Base success rate.
 * : Looting adjustment to the base success rate. Formula is.


 * reference&mdash;Invoke a predicate file and return its result. Invokable from  any context .
 * : The resource location of the predicate to invoke. A cyclic reference causes a parsing failure.


 * survives_explosion&mdash;Returns true with probability. Invokable only from  loot tables , and  fails  when invoked from anything else.


 * table_bonus&mdash;Passes with probability picked from table, indexed by enchantment level.
 * : Id of enchantment.
 * : List of probabilities for enchantment level, indexed from 0.


 * time_check&mdash;Compares the current game time (the age of the world in game ticks) against given values. Invokable from  any context .
 * : The time to compare the game time against.
 * : Number Provider. The minimum value.
 * : Number Provider. The maximum value.
 * : Shorthand version of above, used to check for a single value only. Number providers cannot be used in this shorthand form.
 * : If present, the game time is first reduced modulo the given number before being checked against . For example, setting this to 24000 causes the checked time to be equal to the current daytime.


 * weather_check&mdash;Checks the current game weather. Invokable from  any context .
 * : If true, the condition evaluates to true only if it's raining or thundering.
 * : If true, the condition evaluates to true only if it's thundering.

<div id="condition_value_check" style="margin-block-end: 1em;">
 * value_check&mdash;Compares a number against another number or range of numbers. Invokable from  any context .
 * : Number Provider. The number to test.
 * : The range of numbers to compare against.
 * : Number Provider. The minimum value.
 * : Number Provider. The maximum value.
 * : Shorthand version of above, used to compare  against a single number only. Number providers cannot be used in this shorthand form.

History
Prädikate Prédicat プレディケート 战利品表谓词