Skip to content

[Version 4.10] World Spawn Distance Modifier

Insane96 edited this page May 25, 2024 · 3 revisions

World Spawn Distance Modifier (Inherits from Modifier)

Notes

If operation is "multiply" the result is treated as a percentage increase, the formula is
value * (1 + ((distance + shift) / step) * amount_per_step)
Else if operation is "add" the result is added to the value, the formula is
value + (((distance + shift) / step) * amount_per_step)

Example

With this example, Creepers have 10% chance to spawn with Speed I, increased by 2% flat every 100 blocks from world spawn. So if a creeper spawns 150 blocks from spawn, the chance for Speed I to apply will be 0.10 + ((150 / 100) * 0.02) = 0.10 + 0.03 = 13%

{
    "target": "minecraft:creeper",
    "potion_effects": [
        {
            "id": "minecraft:speed",
            "chance": {
                "value": 0.10,
                "world_spawn_distance_modifier": {
                    "operation": "add",
                    "amount_per_step": 0.02,
                    "step": 100
                }
            }
        }
    ]
}

Here instead, the amount of bonus health the creeper gets is 10 plus 20% more every 100 blocks from spawn. So if a creeper spawns 150 blocks from spawn, the bonus health applied will be 10 * (1 + (150 / 100) * 0.20) = 0.10 * 1.3 = 13

{
    "target": "minecraft:creeper",
    "attributes": [
        {
            "id": "minecraft:generic.max_health",
            "modifier_name": "More Health for Spiders",
            "amount": {
                "value": {
                    "value": 0.15,
                    "world_spawn_distance_modifier": {
                        "operation": "add",
                        "amount_per_step": 0.20,
                        "step": 100
                    }
                }
            },
            "operation": "multiply_base"
        }
    ]
}
Clone this wiki locally