Difficulty (Entity Condition Type)
Passes when the world's difficulty is one of the values you list.
Type ID: apoli:difficulty
Fields
| Field | Type | Default | Description |
|---|---|---|---|
difficulty | String or array | required | One of peaceful, easy, normal or hard, or an array of them. An array passes if the current difficulty is any one of them. |
Examples
A single difficulty:
{
"type": "apoli:difficulty",
"difficulty": "hard"
}Several at once, here a curse that only bites above Easy:
{
"type": "apoli:action_over_time",
"interval": 40,
"entity_action": {
"type": "apoli:damage",
"amount": 1,
"damage_type": "minecraft:magic"
},
"condition": {
"type": "apoli:difficulty",
"difficulty": ["normal", "hard"]
}
}Pair it with apoli:if_else to scale a value instead of switching it on and off:
{
"type": "apoli:if_else",
"condition": { "type": "apoli:difficulty", "difficulty": "easy" },
"if_action": { "type": "apoli:damage", "amount": 1, "damage_type": "minecraft:magic" },
"else_action": { "type": "apoli:damage", "amount": 3, "damage_type": "minecraft:magic" }
}[Expressions](/docs/datapack/data-types/expression) also have a
difficulty variable, which reads 0 for peaceful up to 3 for hard, so "amount": "1 + difficulty" scales without a branch at all.