Skip to main content

If else

saturn:if_else

Runs if_action when the condition holds, otherwise runs else_action.

Runs an operation on a single entity. Used in entity action fields such as entity_action and a trigger rule's action; action arrays run in order.

JSON fields​

FieldTypeRequiredDefaultDescription
typeResource IDyes—saturn:if_else
conditionEntity conditionyes—The condition to check.
if_actionEntity actionyes—Action to run when the condition holds.
else_actionEntity actionno{"type":"saturn:no_op"}Action to run when the condition does not hold.

JSON example​

{
"type": "saturn:if_else",
"condition": {
"type": "saturn:always"
},
"if_action": {
"type": "saturn:no_op"
}
}

This is a value to embed in the corresponding field, not a standalone loadable data pack file. The example: references in the examples must be replaced with defined entries.

Java entry point​

com.iafenvoy.saturn.data.action.builtin.entity.meta.IfElseAction. This page is based on the Codec in the current 26.1.2 source.