If-Else
Executes an action only if a condition holds, and optionally executes another action when it doesn't hold.
Type ID: apoli:if_else
Note
Depending on the condition type, a different action type is expected:
| Action Type | Condition Type |
|---|---|
| Entity Action | Entity Condition |
| Block Action | Block Condition |
| Item Action | Item Condition |
Fields
| Field | Type | Default | Description |
|---|---|---|---|
condition |
Condition | A condition based on the type of action. | |
if_action |
Action | The action which is executed when the condition evaluates to true. | |
else_action |
Action | optional | If present, this action will be executed when the condition evaluates to false. |
Example
"entity_action": {
"type": "apoli:if_else",
"condition": {
"type": "apoli:fall_flying"
},
"if_action": {
"type": "apoli:set_on_fire",
"duration": 5
},
"else_action": {
"type": "apoli:heal",
"amount": 6
}
}
This action will set the target on fire if they are in Elytra flight, or, if not in Elytra flight, will heal the target. The else_action can be omitted to just execute nothing if the condition doesn't hold.