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 a single condition object, keyed type. It is referenced by namespace:path.

⚠ Changed at 26.3

This paragraph used to say the root could also be an array of conditions, an implicit all_of. At 26.3 that is rejected outright — the loader answers Not a JSON object. Use an explicit {"type": "minecraft:all_of", "terms": [ … ]}. Checked by loading both shapes into the 26.3 server, 2026-09-30 (TC-036).

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 condition field. 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).

⚠ Changed at 26.3

Two corrections to what this section used to say. The loot-table key is condition, singular and a single object, not a conditions array — and a plural conditions key is silently ignored rather than refused, so a pack written that way loads clean and behaves as though the condition were absent. And a predicate can no longer be pulled in by id: minecraft:reference is not in the 26.3 registry.

💡 Best practice

This advice no longer works, and the removal is silent. minecraft:reference is not in the 26.3 registry — the game's own datagen lists 20 condition types and that is not one of them, and loading a predicate that uses it fails with Unknown registry key … loot_condition_type. This page recommended it as best practice; it was checked against the 26.3 server on 2026-09-30 and withdrawn (TC-036). To share logic now, write the condition out where it is used, or build the shared part into an all_of you copy.

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:match_blockblock (block ID or #tag), state (map of state → exact value or {min,max} range). Replaces block_state_property, which is not in the 26.3 registry.
minecraft:weather_checkraining (bool, optional), thundering (bool, optional).
minecraft:time_checkclock (required, a world_clock id — vanilla ships minecraft:overworld and minecraft:the_end), value (number provider / range to test), period (int, optional modulo — e.g. 24000 to test time-of-day cyclically). Omitting clock is rejected: No key clock in MapLike[…].
minecraft:environment_attribute_checkTests an environment_attribute, the registry added in 1.21.11.

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:int_value_checkvalue (number provider), range (int range / single value). One half of the split that replaced value_check.
minecraft:float_value_checkvalue (number provider), range (float range / single value). The other half.

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 (combine with all_of)

data/mypack/predicate/night_and_sneaking.json

{
  "type": "minecraft:all_of",
  "terms": [
    { "type": "minecraft:time_check", "clock": "minecraft:overworld",
      "value": { "min": 13000, "max": 23000 }, "period": 24000 },
    { "type": "minecraft:entity_properties", "entity": "this",
      "predicate": { "flags": { "is_sneaking": true } } }
  ]
}
⚠ Changed at 26.3

Three things here used to be written differently, and all three are now rejected by the game — verified by loading each shape into the 26.3 server (TC-036):

  • The root key is type, not condition. A file keyed condition fails with No key type in MapLike[…].
  • A bare array as the file root is rejected — Not a JSON object. This page used to show one and call it “array = all must pass”; wrap the terms in all_of instead.
  • time_check now requires clock, naming a world_clock. Vanilla ships exactly two: minecraft:overworld and minecraft:the_end. Without it: No key clock in MapLike[…].

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

{
  "type": "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

{
  "type": "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

{
  "type": "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