If Else (Meta Action Type)

Executes an action only if a condition holds, and optionally executes another action when it doesn't hold.

Executes an action only if a condition holds, and optionally executes another action when it doesn’t hold.

Type ID: apoli:if_else

Depending on the condition type, a different action type is expected:

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 TypeA condition based on the type of action.
if_actionAction TypeThe action which is executed when the condition evaluates to true.
else_actionAction TypeoptionalIf present, this action will be executed when the condition evaluates to 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 example will set the entity on fire for 5 seconds if they are “sneaking”. Otherwise, it will restore 3 hearts of health to the entity instead.