Skip to main content

If Else (Meta Action Type)

Runs an action when a condition holds, and optionally another action when it doesn't.

Type ID: apoli:if_else

note

The kind of action depends on the kind of condition:

Action typeCondition type
Bi-entity Action TypeBi-entity Condition Type
Entity Action TypeEntity Condition Type
Block Action TypeBlock Condition Type
Item Action TypeItem Condition Type

Fields

FieldTypeDefaultDescription
conditionCondition typerequiredA condition of the kind that matches the action.
if_actionAction typerequiredThe action that runs when the condition is true.
else_actionAction typeoptionalThe action that runs when the condition is false.

Examples

"entity_action": {
    "type": "apoli:if_else",
    "condition": {
        "type": "apoli:sneaking"
    },
    "if_action": {
        "type": "apoli:set_on_fire",
        "duration": 5
    },
    "else_action": {
        "type": "apoli:heal",
        "amount": 6
    }
}

This sets the entity on fire for 5 seconds if it is sneaking, and otherwise restores 3 hearts of health.