If-Else List

Meta Action Type

Checks a list of actions associated with conditions, and executes the first one in the list for which the condition holds. Basically a less indentation-heavy way to represent a deeply nested If-Else (Meta Action Type).

Type ID: origins:if_else_list

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
actions Array of Objects Each object has to have an action Action Type object and a condition Condition Type object.

Examples

"entity_action": {
    "type": "origins:if_else_list",
    "actions": [
        {
            "condition": {
                "type": "origins:health",
                "comparison": "<=",
                "compare_to": 6
            },
            "action": {
                "type": "origins:apply_effect",
                "effect": {
                    "effect": "minecraft:speed",
                    "amplifier": 2,
                    "duration": 80
                }
            }
        },
        {
            "condition": {
                "type": "origins:health",
                "comparison": "<=",
                "compare_to": 12
            },
            "action": {
                "type": "origins:apply_effect",
                "effect": {
                    "effect": "minecraft:speed",
                    "amplifier": 1,
                    "duration": 80
                }
            }
        },
        {
            "condition": {
                "type": "origins:health",
                "comparison": "<=",
                "compare_to": 18
            },
            "action": {
                "type": "origins:apply_effect",
                "effect": {
                    "effect": "minecraft:speed",
                    "amplifier": 0,
                    "duration": 80
                }
            }
        }
    ]
}

This example will apply a stronger Speed status effect the lower the entity's health is, in three stages (<= 3 hearts, <= 6 hearts or <= 9 hearts).