If-Else
Executes an action only if a condition holds, and optionally executes another action when it doesn't hold.
Type ID: origins:if_else
Note
Depending on the condition type, a different action type is expected:
Action Type | Condition Type |
---|---|
Bi-entity Action Type | Bi-entity Condition Type |
Entity Action Type | Entity Condition Type |
Block Action Type | Block Condition Type |
Item Action Type | Item Condition Type |
Fields
Field | Type | Default | Description |
---|---|---|---|
condition |
Condition Type | A condition based on the type of action. | |
if_action |
Action Type | The action which is executed when the condition evaluates to true. | |
else_action |
Action Type | optional | If present, this action will be executed when the condition evaluates to false. |
Examples
"entity_action": {
"type": "origins:if_else",
"condition": {
"type": "origins:fall_flying"
},
"if_action": {
"type": "origins:set_on_fire",
"duration": 5
},
"else_action": {
"type": "origins:heal",
"amount": 6
}
}
This example will set the entity on fire for 5 seconds if they are "fall flying". Otherwise, it will restore 3 hearts of health to the entity instead.