If-Else List

Meta Action.

Currently only available as an Entity Action

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 Action.

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

Type ID: apoli:if_else_list

Fields

Field Type Default Description
actions Array Array of Objects, each with an action Action and a condition Condition.

Example

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

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