Skip to main content

โš–๏ธ Conditions

tip

Adding ! before a condition type inverts its logic. For instance:

type: "!permission"
permission: "craftengine.admin"

any_ofโ€‹

Satisfy any one of the conditions.

type: any_of
terms:
- type: xxx
- type: xxx

all_ofโ€‹

All conditions must be satisfied.

type: all_of
terms:
- type: xxx
- type: xxx

invertedโ€‹

Negate the result value of the current condition.

type: inverted
term:
type: xxx

falling_blockโ€‹

Check whether the drop was caused by the block falling.

type: falling_block

survives_explosionโ€‹

Detect whether it is possible to survive the explosion.

type: survives_explosion

has_itemโ€‹

Check if there is any item in hand

type: has_item

match_itemโ€‹

Match the item in hand.

type: match_item
id: "minecraft:iron_pickaxe"
regex: false # whether to use regex matching
type: match_item
id:
- "minecraft:iron_pickaxe"
- "minecraft:stone_pickaxe"
regex: false # whether to use regex matching

match_block_propertyโ€‹

Match the block state property

type: match_block_property
properties:
age: 3

match_blockโ€‹

Match the block type

type: match_block
x: <arg:position.x>
y: <arg:position.y>
z: <arg:position.z>
id: minecraft:stone
regex: false

match_entityโ€‹

Match the entity type

type: match_entity
id: minecraft:enderman
regex: false

match_furniture_variantโ€‹

Match the furniture variant

type: match_furniture_variant
variants:
- wall

enchantmentโ€‹

Detect the enchantments on the item in hand.

type: enchantment
predicate: minecraft:silk_touch>=1 # > >= = < <=

equipmentโ€‹

Check if the item in a specific equipment slot matches the configured item ID or tag. The slot aliases and the ID/tag check use OR logic.

type: equipment
slot: head # required; enum[mainhand, offhand, head, chest, legs, feet, body, saddle]
id: "minecraft:diamond_helmet" # optional; string/string list; item ID to match
tag: ["my_pack:custom_tag"] # optional; string list; tag to match (OR logic with id)
regex: false # optional; boolean; default: false; whether id uses regex matching
# Example: match by item ID with regex
type: equipment
slot: chest
id: ["minecraft:.*_chestplate"]
regex: true
# Example: match by tag only
type: equipment
slot: feet
tag: ["my_pack:fire_resistant"]

equipment_setโ€‹

Checks how many pieces of a specified equipment set the player or entity in the current context is wearing.

# type: always equipment_set. Required
type: equipment_set
# set / id: set ID to count. Required
set: demo:guardian
# count / amount: optional exact piece count; when present, min and max are ignored
# count: 2
# min / min_count / min-count: inclusive lower bound. Default: 1
min: 2
# max / max_count / max-count: inclusive upper bound. No upper limit by default
# max: 4

The result is false if no player or entity is available in the condition context, or if the entity is not tracked. To match zero pieces, explicitly use count: 0. Specifying only set means โ€œat least one piece.โ€

table_bonusโ€‹

Provide different success probabilities at various enchantment levels.

type: table_bonus
enchantment: minecraft:fortune
chances:
- 0.1
- 0.5
- 0.8
- 1

randomโ€‹

type: random
value: 0.1 # 10%

By default every check rolls independently. Specify an id to share one roll across multiple checks within the same context:

type: random
value: 0.1
id: crit # all random conditions with id "crit" in this context use the same roll

permissionโ€‹

Checks if the player has the permission

type: permission
permission: "craftengine.admin"

has_discovered_recipeโ€‹

Check whether the context player has unlocked a recipe. Returns false when the context has no player. Use discover_recipe to unlock a recipe.

type: has_discovered_recipe
recipe: "mypack:custom_recipe" # required; string; recipe ID; alias: id

expressionโ€‹

Checks if the expression returns true

type: expression
# https://github.com/Xiao-MoMi/sparrow-expression
expression: "<papi:farming_level> >= 10"

string_equalsโ€‹

Determines if the two values are equal

type: string_equals
value1: "<arg:player.name>"
value2: "Player_A"

string_containsโ€‹

Determines if value1 contains value2

type: string_contains
value1: "<arg:player.name>"
value2: "A"

regexโ€‹

Determines if value matches the pattern

type: regex
value: "<arg:player.name>"
regex: "[a-Z]"

is_nullโ€‹

Checks if the argument is null

type: is_null
argument: "player.main_hand_item"

handโ€‹

Checks the interaction hand

type: hand
hand: main_hand # off_hand

on_cooldownโ€‹

Checks if player is on cooldown (use set_cooldown function to set cooldown for player)

type: on_cooldown
id: my_cooldown_id
info

Example usage

events:
- on: right_click
functions:
- type: set_cooldown
id: test
time: 30s
- type: command
command: give <arg:player.name> minecraft:apple
conditions:
- type: "!on_cooldown"
id: test

on_item_cooldown (1.21.2+)โ€‹

Checks whether the player is on cooldown for the specified item cooldown group. Use set_item_cooldown to set the cooldown.

type: on_item_cooldown
id: "minecraft:ender_pearl" # required; string; cooldown group

worldguard:regionโ€‹

Check whether the location in the current context is within a WorldGuard region.

type: worldguard:region
# Mode 1 represents union of regions
# Mode 2 represents intersection of regions
mode: 1
regions:
- A
- B

distanceโ€‹

Check whether the distance between the player and the context's position within the current context falls within the specified range.

type: distance
min: 0
max: 32

has_playerโ€‹

Check if player exists in this context

type: has_player

has_moneyโ€‹

Check whether the player has enough money (requires Vault and an economy plugin)

type: has_money
amount: 100 # required; number/expression

inventory_has_itemโ€‹

Detect whether the specified item or quantity is present in the current context player's inventory.

type: inventory_has_item
id: "minecraft:iron_pickaxe"
count: 1

is_bedrock_playerโ€‹

Check whether the player is a bedrock player.

type: is_bedrock_player

test_flagโ€‹

Test flags at the target location

type: test_flag
flag: break # break, place, interact, open_container

jsโ€‹

Evaluates a JavaScript function as the condition (must return a boolean). See ๐Ÿ“œ Scripting for the full scripting guide.

type: js
script: "mypack:combo" # required; string; script id (<namespace>:<path without .js>)
function: "canUse" # optional; string; default: main
# args - optional; list or map (injected as `args`, or as named bindings)
args:
min_level: 10
info

More conditions are coming...