If Else Action - apace100/origins-fabric GitHub Wiki

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

Type ID: origins:if_else

Fields:

condition, Conditions: A condition based on the type of action, see Notes section at the bottom of this page.

if_action, Actions: The action which is executed when the condition evaluates to true.

else_action, Actions, optional: If present, this action will be executed when the condition evaluates to false.

Example:

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

Notes:

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

Important: When used as an Entity Action, this will only have an effect on players, due to the way the conditions are implemented at the moment. Might change in the future.