Skip to content

Random Chance

Generates a random number between 0.0 and 1.0, and executes an action if it's less than a specified chance.

Type ID: kaya:random_chance

Format

Field Type Default Description
success_action Action The action to execute if the chance is less than the random number.
fail_action Action optional If specified, this action will be executed if the chance is greater or equal to the random number.
chance Float Provider The success rate as a number. The value is clamped within the range of 0.0 to 1.0.
Tip

You can convert an integer chance value to float by using the following formula: $(Chance = Value / 100)$ (e.g: $(65 / 100 = 0.65)$)

Example

{
    "type": "kaya:random_chance",
    "success_action": {
        "type": "kaya:set_entity_on_fire",
        "ticks": 200,
        "entity": "this"
    },
    "chance": 0.50
}

This example will set the entity provided by the kaya:this_entity context parameter on fire for 10 seconds at a 50% chance.

History

Minecraft Mod Changelog
1.21.5 0.1.0 Added the type.