Predicates

A predicate is a reusable JSON condition β€” the exact same system as loot-table conditions β€” that you reference from loot tables, advancements, item modifiers and the /execute if predicate command to test complex entity, item, location and world state.

File location & structure

Each predicate is one JSON file under the singular 1.21+ folder:

data/<namespace>/predicate/<path>.json

data/mypack/predicate/holding_diamond_sword.json  β†’ referenced as mypack:holding_diamond_sword

The file's root is either a single condition object or an array of conditions (ALL must pass β€” an implicit all_of). It is referenced by namespace:path.

One system: conditions == predicates

There is no separate "predicate language". A predicate file contains the very same condition objects that appear inline in a loot table's conditions array. The full list below is identical to the loot-condition list on the loot tables page β€” the difference is only where the condition lives (a standalone file vs. inline). Anything you can write in a loot pool's conditions, you can save as a predicate and pull back in with reference.

πŸ’‘ Best practice

Factor shared logic into one predicate file and reference it everywhere with {"condition":"minecraft:reference","name":"mypack:x"} β€” inside loot tables, advancements and other predicates. One canonical definition, many call sites.

Condition types (full list)

Logical

ConditionFields
minecraft:all_ofterms (array of conditions) β€” passes if all pass.
minecraft:any_ofterms (array) β€” passes if any pass.
minecraft:invertedterm (single condition) β€” negates it.

Entity / scores

ConditionFields
minecraft:entity_propertiesentity (context ref: this, attacker, direct_attacker, attacking_player, target_entity, …), predicate (entity sub-predicate).
minecraft:entity_scoresentity (context ref), scores (map objective β†’ int range or single value).
minecraft:killed_by_playerNo fields; requires attacking_player in context.

Items / tools

ConditionFields
minecraft:match_toolpredicate (item sub-predicate). In loot context checks the mining tool; in other contexts the relevant tool.

Location / world

ConditionFields
minecraft:location_checkpredicate (location sub-predicate), optional integer offsetX / offsetY / offsetZ.
minecraft:block_state_propertyblock (block ID), properties (map of state β†’ exact value string or {min,max} range).
minecraft:weather_checkraining (bool, optional), thundering (bool, optional).
minecraft:time_checkvalue (number provider / range to test), period (int, optional modulo β€” e.g. 24000 to test time-of-day cyclically).

Randomness

ConditionFields
minecraft:random_chancechance (float 0–1; a number provider since 1.21).
minecraft:random_chance_with_enchanted_bonusunenchanted_chance (float), enchanted_chance (level-based number provider), enchantment (enchantment ID). 1.21 restructure of the old looting-based random chance.
minecraft:table_bonusenchantment (ID), chances (array of floats indexed by enchantment level).
minecraft:survives_explosionNo fields; passes with probability 1 / explosion_radius.

Damage / enchantment

ConditionFields
minecraft:damage_source_propertiespredicate (damage-source sub-predicate: tags, source_entity, direct_entity, is_direct, …).
minecraft:enchantment_active_checkactive (bool); used inside enchantment-provided effects to test whether the enchantment is currently active.

Misc

ConditionFields
minecraft:value_checkvalue (number provider), range (int range / single value to compare against).
minecraft:referencename (resource location of another predicate file).

Entity sub-predicate

Used by entity_properties (and reused by advancement triggers). All fields are optional; a missing field is not tested.

FieldChecks
typeEntity type: ID, #tag, or array.
type_specificType-scoped props: { "type": "player"|"raider"|"sheep"|"fishing_hook"|"lightning"|"cat"|"frog"|"axolotl"|"slime"/"cube_mob"|…, …props }. E.g. player: gamemode, level, stats, recipes, advancements, look_at.
nbtPartial SNBT match (slowest β€” evaluated last).
teamScoreboard team name.
locationLocation sub-predicate (where the entity is).
stepping_onBlock predicate for the block being stood on.
movement_affected_byBlock predicate ~0.5 below the feet.
distance{ absolute|horizontal|x|y|z : float range } to context origin.
movementVelocity: { x|y|z|speed|horizontal_speed|vertical_speed|fall_distance : range }.
flagsBooleans: is_on_fire, is_sneaking, is_sprinting, is_swimming, is_baby, is_on_ground, is_flying, is_fall_flying.
equipmentPer-slot item sub-predicates: mainhand, offhand, head, chest, legs, feet, body.
slotsItem sub-predicates keyed by slot range (e.g. container.5, hotbar.0, weapon.mainhand).
effectsMap effect ID β†’ { amplifier(range), duration(range), ambient(bool), visible(bool) }.
vehicleEntity sub-predicate for the ridden entity.
passengerEntity sub-predicate for a direct passenger.
targeted_entityEntity sub-predicate for the mob's AI target.
periodic_tickInt; passes when entity age is divisible by it.

Item sub-predicate 1.20.5+

Used by match_tool, equipment/slots, and advancement item triggers. Since 1.20.5 it is component-based (see data components).

FieldChecks
itemsItem ID, #tag, or array of IDs (type match).
countInt, or { min, max } range (stack size).
componentsEXACT component match: { "minecraft:<component>": <value>, … } β€” the item must have exactly this component value.
predicatesLOOSER component checks (partial / ranged). Keys are data-component predicate types (below).

Data-component predicate types

These are the keys usable inside the item sub-predicate's predicates field β€” structured, partial or ranged checks against individual components.

PredicateChecks
minecraft:damageRemaining durability / damage value (ranges).
minecraft:enchantmentsEnchantments on the item (ID + level range).
minecraft:stored_enchantmentsEnchantments stored on an enchanted book.
minecraft:potion_contentsThe potion field of potion_contents.
minecraft:custom_dataThe custom_data component (partial SNBT).
minecraft:containerItem stacks inside container.
minecraft:bundle_contentsItem stacks inside bundle_contents.
minecraft:firework_explosionThe firework_explosion component.
minecraft:fireworksExplosions in the fireworks component.
minecraft:writable_book_contentPages in writable_book_content.
minecraft:written_book_contentThe written_book_content component.
minecraft:trimThe trim component.
minecraft:jukebox_playableSong in jukebox_playable.
minecraft:attribute_modifiersModifiers in attribute_modifiers.

Location, block & fluid sub-predicates

Used by location_check and by the entity sub-predicate's location / stepping_on / movement_affected_by fields. All fields optional.

Location fieldType / checks
biomesBiome ID, #tag, or array of IDs.
dimensionDimension ID (e.g. minecraft:the_nether).
structuresStructure ID, #tag, or array of IDs.
position{ x, y, z }, each a float range.
light{ light: <int range> } β€” the light level at the position.
smokeyBoolean β€” whether the position is above a campfire (smoke).
can_see_skyBoolean β€” sky visibility at the position.
blockBlock sub-predicate (below).
fluidFluid sub-predicate (below).
Block sub-predicate fieldChecks
blocksBlock ID, #tag, or array of IDs (type match).
stateMap of block-state property β†’ exact value or {min,max} range.
nbtPartial block-entity SNBT match.
components / predicatesExact / looser component checks on the block item (optional).
Fluid sub-predicate fieldChecks
fluidsFluid ID, #tag, or array of IDs.
stateMap of fluid-state property β†’ exact value or range (e.g. level, falling).

Damage-source sub-predicate

Used by damage_source_properties to test how the damage was dealt.

FieldChecks
tagsDamage-type tags (e.g. #minecraft:is_fire), each with an expected boolean.
source_entityEntity sub-predicate for the logical source (e.g. the shooter of an arrow).
direct_entityEntity sub-predicate for the immediate cause (e.g. the arrow itself).
is_directBoolean β€” whether the direct entity is also the source.

Using predicates

In commands β€” /execute if predicate

The cleanest way to test complex entity state (equipment, effects, scores, location, NBT) without long selector arguments:

execute as @a if predicate mypack:holding_diamond_sword run say I am armed
execute if predicate mypack:night_and_sneaking run function mypack:stealth/tick

In loot tables, item modifiers & advancements

Worked examples

Detect sneaking at night (array = all must pass)

data/mypack/predicate/night_and_sneaking.json

[
  { "condition": "minecraft:time_check", "value": { "min": 13000, "max": 23000 }, "period": 24000 },
  { "condition": "minecraft:entity_properties", "entity": "this",
    "predicate": { "flags": { "is_sneaking": true } } }
]

Use: execute as @a if predicate mypack:night_and_sneaking run …

Holding a custom item via custom_data

data/mypack/predicate/holding_magic_wand.json

{
  "condition": "minecraft:entity_properties",
  "entity": "this",
  "predicate": {
    "equipment": {
      "mainhand": {
        "items": "minecraft:stick",
        "predicates": {
          "minecraft:custom_data": "{magic_wand:1b}"
        }
      }
    }
  }
}

This matches any player holding a stick whose custom_data component contains magic_wand:1b β€” the standard way to identify a datapack "custom item".

Biome check

data/mypack/predicate/in_desert.json

{
  "condition": "minecraft:location_check",
  "predicate": {
    "biomes": "minecraft:desert",
    "can_see_sky": true
  }
}

Use: execute as @a at @s if predicate mypack:in_desert run …. Note location_check tests the context origin β€” with at @s that is the entity's position; add offsetX/Y/Z to test a nearby block instead.

Holding a diamond sword (simple item match)

data/mypack/predicate/holding_diamond_sword.json

{
  "condition": "minecraft:entity_properties",
  "entity": "this",
  "predicate": {
    "equipment": {
      "mainhand": { "items": "minecraft:diamond_sword" }
    }
  }
}

Tricks & best practices

πŸ’‘ Best practice

/execute if predicate is the cleanest way to test complex entity state without long, brittle target-selector arguments β€” reach for a predicate whenever a selector's [...] arguments start to sprawl.

⚠ Gotcha

The nbt field is slow β€” it is evaluated last and matches raw SNBT. Always constrain with type, flags or components/predicates first, and put nbt last so the fast checks short-circuit it.

🎩 Trick

Because predicates and loot conditions are one system, you can prototype a gate inline in a loot table, then lift it verbatim into a predicate/ file and share it across advancements, item modifiers and /execute β€” no translation needed.

Version differences

⚠ Version differences
  • Since 1.20.5 (pack_format 41): the item sub-predicate became component-based. The old item, tag, nbt, durability, enchantments, potion fields collapsed into items plus components (exact) and predicates (structured/ranged). See data components.
  • Since 1.21 (pack_format 48): the folder predicates was singularised to predicate.
  • Since 1.21: random_chance_with_enchanted_bonus replaced the old looting-based random-chance condition, and its (and random_chance's) chance fields became number providers.
  • Since 1.21: entity context refs renamed: killer β†’ attacker, direct_killer β†’ direct_attacker, killer_player β†’ attacking_player.

Sources