Entity Condition Types
An entity condition checks the state of a single entity and returns true or false. The entity being tested is supplied by whatever data table declares the condition, so the condition itself only describes what to check.
Entity conditions are a Java (built-in) registry, so their type ids are fixed and a data pack cannot add new ones. type selects the built-in type and its value is one of the ids tabulated on this page, written with the mxt namespace. A data pack never adds or removes entries in this registry. Only Java code or the KubeJS bridge can introduce custom condition types — see the KubeJS API.
In the table below, a field name followed by ? is optional; every other listed field must be present. The Fields column lists the JSON keys taken directly from the type's codec.
Common Structure
A condition is a JSON object whose type field names the built-in type. All remaining keys are the fields declared by that type.
{
"type": "mxt:health",
"comparison": "<",
"compare_to": 10
}Because conditions are used as values inside other data tables, the same structure usually appears nested under a field such as condition:
"condition": {
"type": "mxt:has_spirit_root",
"spirit_root": "example:azure_root"
}Anywhere an entity condition is expected, an array of conditions is also accepted. The array is shorthand for mxt:and and passes only when every entry passes:
"condition": [
{ "type": "mxt:sneaking" },
{ "type": "mxt:on_block", "condition": {"type": "mxt:block_tag", "tag": "minecraft:logs"} }
]Comparison Fields
Several types compare a value against a number. When a type lists comparison and compare_to as separate keys, they sit directly on the condition object, as in the example above. A few types instead name a single comparison key whose value is one nested comparison object holding comparison and compare_to; those types say so in their description. The comparison operators are ==, !=, <, <=, > and >=, and compare_to itself is always a plain number.
Datapack Visual Editor
The Datapack Visual Editor shows the field list of every type interactively, which is handy for checking a field name without reading the table here.
Condition Types
| Type | Fields | Description |
|---|---|---|
mxt:always_true | — | Always passes. |
mxt:js | id, params? | Calls an entity condition handler that was registered through the KubeJS bridge. |
mxt:never | — | Always fails. |
mxt:and | conditions | Passes only when every nested entity condition passes. |
mxt:not | condition | Negates a nested entity condition. |
mxt:or | conditions | Passes when at least one nested entity condition passes. |
mxt:chance | chance | Passes randomly with the given probability between 0 and 1. |
mxt:constant | value | Always returns the given boolean value. |
mxt:sneaking | — | Checks whether the entity is sneaking. |
mxt:has_ability | ability | Checks whether the entity currently holds the given ability. |
mxt:has_curse | curse?, tags?, stacks?, remaining_ticks? | Checks whether the entity holds one curse that satisfies every filter given: a definition, all of the listed tags, a stack range and a remaining-tick range. The ranges are {min?, max?} windows; a curse that never expires counts as infinite, so it answers a min but never a max. With no filter at all it asks whether any curse is held. |
mxt:has_spirit_root | spirit_root | Checks whether the entity currently holds the given spirit root. |
mxt:has_physique | physique | Checks whether the entity currently holds the given physique. |
mxt:realm | realm, comparison? | Compares the entity's realm stage against realm, using exact (the default), at_least or at_most. |
mxt:has_realm | aura | Passes for entities that have entered a realm chain for the given aura. |
mxt:aura_range | aura | Tests the server-resolved aura concentration at the entity's position against per-aura requirements. aura maps an aura ID to an object with a required max and an optional min (default 0); both accept a number provider. |
mxt:resource_compare | resource, min | Checks that the entity's value for a resource is at least min. |
mxt:entity_tag | tag | Matches the entity against an entity type tag. |
mxt:formation_member | — | Passes when the entity owns any registered formation in the current level. |
mxt:formation_owner | — | Passes when the entity owns the formation currently being evaluated; outside a formation context it is false. |
mxt:formation_ally | — | Passes when the owner of the formation currently being evaluated treats the entity as an ally. |
mxt:air | comparison, compare_to | Compares the entity's remaining air. |
mxt:dimension | dimension, inverted? | Checks the entity's dimension, or the opposite when inverted is true. |
mxt:entity_type | entity_type | Checks the entity's type. |
mxt:fall_distance | comparison, compare_to | Compares the entity's fall distance. |
mxt:glowing | — | Checks whether the entity is glowing. |
mxt:health | comparison, compare_to | Compares the entity's current health. |
mxt:exposed_to_sky | — | Checks whether the entity's position can see the sky. |
mxt:food_level | comparison, compare_to | Compares a player's food level. |
mxt:mob_effect | effect | Checks whether the entity has the given status effect. |
mxt:on_block | condition | Tests a block condition against the block the entity stands on. |
mxt:time_of_day | comparison, compare_to | Compares the overworld clock time, in ticks within a 24000 tick day. |
mxt:using_item | — | Checks whether the entity is currently using an item. |
mxt:brightness | comparison, compare_to | Compares the brightness at the entity's eyes as a value between 0 and 1. |
mxt:exposed_to_sun | — | Checks whether the entity is exposed to sunlight. |
mxt:experience_level | comparison, compare_to | Compares a player's experience level. |
mxt:experience_points | comparison, compare_to | Compares a player's total experience points. |
mxt:relative_health | comparison, compare_to | Compares the entity's health divided by its maximum health. |
mxt:saturation_level | comparison, compare_to | Compares a player's saturation level. |
mxt:team | team? | Checks whether the entity is on a scoreboard team, or on the named team when team is present. |
mxt:attribute | attribute, comparison, compare_to | Compares one of the entity's attribute values. |
mxt:block_collision | offset_x?, offset_y?, offset_z? | Checks for a block collision at an offset from the entity. |
mxt:can_have_effect | effect | Checks whether the entity can be affected by the given status effect. |
mxt:gamemode | gamemode | Checks a player's game mode. |
mxt:passenger | bientity_condition?, comparison, compare_to | Compares the number of the entity's direct passengers that satisfy a bi-entity condition. |
mxt:attack_cooldown | comparison, compare_to | Compares a player's current attack cooldown progress. |
mxt:equipped_item | equipment_slot, item_condition? | Checks the item in one equipment slot against an item condition. |
mxt:in_block | block_condition | Tests a block condition against the single block at the entity's block position. |
mxt:in_block_anywhere | block_condition, comparison | Compares the number of matching blocks inside the entity's bounding box, with comparison as a nested comparison object. |
mxt:scoreboard | name?, objective, comparison, compare_to | Compares a scoreboard score, defaulting the score holder to the entity's scoreboard name. |
mxt:riding | bientity_condition? | Checks the entity's vehicle against a bi-entity condition. |
mxt:riding_recursive | bientity_condition?, comparison, compare_to | Compares the number of vehicles in the whole riding chain that satisfy a bi-entity condition. |
mxt:passenger_recursive | bientity_condition?, comparison, compare_to | Compares the number of nested passengers that satisfy a bi-entity condition. |
mxt:riding_root | bientity_condition? | Tests a bi-entity condition against the vehicle at the root of the entity's riding chain. |
mxt:storage_toggle | family, id, expected? | Reads a mxt:toggle value. family names the data pack registry the host lives in, id the host; the host must declare that kind or the test is false. True when the stored state equals expected (default true), falling back to the declaration's default while nothing was ever written. |
mxt:storage_timer | family, id, remaining?, ended? | Reads a mxt:timer value. remaining is a {min?, max?} window over the ticks left (never negative), ended asks whether ends_at has passed. A timer with no ends_at is not running, so it has nothing left and counts as ended. |
mxt:storage_resource | family, id, amount? | Reads a mxt:resource value. amount is a {min?, max?} window; a stored record without an amount counts as 0, and omitting amount only asks whether a value of that kind is stored at all. |
mxt:storage_target | family, id, locked?, max_distance? | Reads a mxt:target_lock value. locked (default true) asks whether a target UUID is stored; max_distance additionally requires that UUID to parse and resolve to an entity in the actor's level within that distance. A malformed UUID, a missing entity or a negative distance is false. |
mxt:storage_charges | family, id, remaining? | Reads a mxt:charges value. remaining is a {min?, max?} window over the uses left; a pool that was never spent keeps no count and reads as the declaration's maximum. Omitting remaining only asks whether the host declares a charge pool at all. |
mxt:storage_cooldown | family, id, remaining?, ready? | Reads a mxt:cooldown value. remaining is a {min?, max?} window over the ticks left and ready asks whether the cooldown has finished. The length is the one the last use actually got, or the declaration's own ticks for a value content wrote without a duration; the countdown starts at the tick the value was written, the same anchor the runtime reads. A host that never wrote one is not cooling down at all, so it answers remaining 0 and ready true. |
mxt:has_equipped_item | item_condition?, slots? | Passes when the entity wears or holds a stack satisfying an item condition — the natural way to gate a passive mxt:modifier on gear, for example {"type": "mxt:item_tag", "tag": "#example:swords"}. slots names vanilla equipment slots (mainhand, offhand, head, chest, legs, feet, body) or Curios slots with a curios: prefix (curios:back_weapon); leaving it out asks every vanilla slot and every Curios slot. A name that matches nothing simply never passes. |
Type References
ability, curse, spirit_root, physique, realm, aura and resource accept the ids of the matching data pack registries, so they can point at content added by any data pack, not only at entries shipped with the mod.