Predicate

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, the target selector argument, or from loot conditions within other files.

Inside a data pack, predicate files are located within.

JSON format
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;Evaluates a list of predicates and succeeds only if at least one of them succeeds. Invokable from  any context .
 * : The list of predicates to evaluate. Predicates within this array must be, they cannot themselves be arrays.
 * A predicate.


 * 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;Checks properties of damage source. Invokable from  advancements  or  loot tables , and  fails  when invoked from anything else.
 * : Predicate applied to the damage source.


 * entity_properties&mdash;Checks properties of an entity. 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;Checks 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;Inverts another loot table condition. Invokable from  any context .
 * : The condition to be negated, following the same structure as outlined here, recursively.


 * killed_by_player&mdash;Checks 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.


 * location_check&mdash;Checks 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;Generates a random number between 0.0 and 1.0, and checks 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;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  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;Invokes a predicate file and returns 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.


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

<div class="treeview" id="condition_weather_check" style="margin-block-end: 1em;">
 * 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.

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