Skip to content

Horde Scripts

Smileycorp edited this page May 2, 2026 · 24 revisions

Scripts are how the mod works out which type of horde to send on any given night. You can find them located at the data/<identifier>/horde_scripts folder in your datapack in version 1.2.X and at data/<identifier>/horde_data/scripts in 1.3.+ folder in your datapack.

You can have multiple scripts loaded in this folder and they will run sequentially in alphabetical order. Prior to 1.4.0 you could only have 1 function per file, now you can have multiple provided they are formatted in a json array format like the default script in 1.4.1+

Default Script 1.5.0+
[
    {
        "function": "hordes:set_spawntable",
        "value": [
            "hordes:default"
        ],
        "conditions": []
    },
    {
        "function": "hordes:multiple",
        "value": [
            {
                "function": "hordes:set_spawntable",
                "value": [
                    "hordes:drowned"
                ],
                "conditions": []
            },
            {
                "function": "hordes:set_spawn_type",
                "value": "prefer_water",
                "conditions": []
            }
        ],
        "conditions": [
            {
                "name": "hordes:biome",
                "value": "#minecraft:is_ocean"
            },
            {
                "name": "hordes:not",
                "value": {
                    "name": "hordes:biome",
                    "value": [
                        "minecraft:frozen_ocean",
                        "minecraft:deep_frozen_ocean"
                    ]
                }
            }
        ]
    }
]

If your script has an error in it, or there are no script files, an error message will be printed in the latest.log file, as well as the hordes.log file and the table hordes:fallback , which only contains zombies wearing pumpkins will be loaded instead.

The default script, shown below will load the default table every time the mod tries to start a horde event.

Default Script (Pre 1.4.1)
{
	"function": "hordes:set_spawntable",
	"value": [
		"hordes:default"
	],
	"conditions": []
}

This simply sets the table to hordes:default.

Functions

Functions describe an operation that the mod will perform when trying to start a horde, or spawn horde waves.

There are two types of functions Spawndata and Spawn Event, these cannot be used in the same script files as each other and trigger at different times.

In addition there are universal functions that can be used for either event.

Univeral Functions

hordes:multiple (1.4.0+)

Example
{
	"function": "hordes:multiple",
	"value": [
		{
			"function": "hordes:set_spawntable",
			"value": [
				"hordes:drowned"
			],
			"conditions": []
		},
		{
			"function": "hordes:set_spawn_type",
			"value": "prefer_water",
			"conditions": []
		}
	],
	"conditions": [
		{
			"name": "hordes:biome",
			"value": "#minecraft:is_ocean"
		}
	]
}

hordes:multiple allows you to group multiple functions that will all trigger if the conditions are met.

The above example is taken from the default script, it sets the table to the hordes:drowned table and sets horde mobs to prefer spawning in water, if the player the horde starts on is in an ocean biome.

hordes:random (1.6.3+)

Example
{
	"function": "hordes:random",
	"value": [
		{
			"function": "hordes:set_spawntable",
			"value": "hordes:skeletons",
			"conditions": []
		},
		{
			"function": "hordes:multiple",
			"value": [
				{
					"function": "hordes:set_spawntable",
					"value": "hordes:illagers",
					"conditions": []
				},
				{
					"function": "hordes:set_spawn_sound",
					"value": "event.raid.horn",
					"conditions": []
				}
			],
			"conditions": []
		}
	],
	"conditions": []
}

hordes:random allows you to define a set of functions that will be randomly selected from if the condition passes.

This function checks conditions and removes any functions who's conditions are not met before it rolls which function to run.

The above example randomly sets the horde to either use the hordes:skeletons table or the hordes:illagers table and play the raid horn sound.

hordes:weighted_random (1.6.3+)

Example
{
	"function": "hordes:weighted_random",
	"value": [
		{
			"function": "hordes:set_spawntable",
			"value": "hordes:skeletons",
			"conditions": []
			"weight": 6
		},
		{
			"function": "hordes:multiple",
			"value": [
				{
					"function": "hordes:set_spawntable",
					"value": "hordes:illagers",
					"conditions": []
				},
				{
					"function": "hordes:set_spawn_sound",
					"value": "event.raid.horn",
					"conditions": []
				}
			],
			"conditions": [],
			"weight": 4
		}
	],
	"conditions": []
}

hordes:weighted_random allows you to define a set of functions that will be randomly selected from if the condition passes, at a set weight, similar to how horde tables or vanilla loot tables work, higher numbers are more likely to get chosen.

This function checks conditions and removes any functions who's conditions are not met before it rolls which function to run. The above example randomly sets the horde to either use the hordes:skeletons table 6 out of 10 times or the hordes:illagers table and play the raid horn sound the other 4.

hordes:set_entity_nbt (spawndata only prior to 1.6.3)

Example
{
	"function": "hordes:set_entity_nbt",
	"value": "{HandItems:[{id:stone_sword,Count:1}]}",
	"conditions": []
}

hordes:set_entity_nbt modifies the nbt of an entity, for spawn events this is the entity being spawned, for spawndata events this is always the player the horde is running for.

The above example gives a stone sword to entities spawned.

hordes:set_player_nbt (1.6.3+)

Example
{
	"function": "hordes:set_player_nbt",
	"value": "{Fire:20}",
	"conditions": []
}

hordes:set_player_nbt can modify the current player's nbt data,

The above example sets the player on fire for 20 ticks.

hordes:set_variable (1.6.3+)

Example
{
	"function": "hordes:set_variable",
	"value": {
		"type": "int",
		"key": "phase",
		"value": 3
	}
	"conditions": []
}

hordes:set_variable sets a variable to the current executing event, which can be read later during script execution.

hordes:call_script (1.6.3+)

Example
{
	"function": "hordes:call_script",
	"value": "hordes:set_drowned_wave",
	"conditions": []
}

hordes:call_script runs another script file in the scripts folder before returning to the current script and continuing to execute it.

The above example opens the script called set_drowned_wave.json in the scripts folder.

hordes:break (1.6.3+)

Example
{
	"function": "hordes:multiple",
	"value": [
		{
			"function": "hordes:set_spawntable",
			"value": "hordes:skeletons",
			"conditions": []
		},
		{
			"function": "hordes:break",
			"conditions": []
		},
		{
			"function": "hordes:set_spawntable",
			"value": "hordes:illagers",
			"conditions": []
		},
	],
	"conditions": []
}

hordes:break stops executing the current hordes:multiple function before the next function is called.

The above example breaks out of the function after the spawntable is set to hordes:skeletons but before it gets reassigned.

hordes:return (1.6.3+)

Example
{
	"function": "hordes:multiple",
	"value": [
		{
			"function": "hordes:set_spawntable",
			"value": "hordes:skeletons",
			"conditions": []
		},
		{
			"function": "hordes:return",
			"conditions": []
		},
		{
			"function": "hordes:set_spawntable",
			"value": "hordes:illagers",
			"conditions": []
		},
	],
	"conditions": []
}

hordes:return stops executing the current script before the next function is called. This is best used with hordes:call_script to return to the original script early.

The above example returns from the script after the spawntable is set to hordes:skeletons but before it gets reassigned.

hordes:cancel (1.6.3+)

Example
{
	"function": "hordes:multiple",
	"value": [
		{
			"function": "hordes:cancel",
			"conditions": []
		},
		{
			"function": "hordes:return",
			"conditions": []
		}
	],
	"conditions": []
}

hordes:cancel cancels the current executing event, for spawndata events this prevents the horde event from starting, for spawn entity events, this stops the entity from being spawned.

This event does not return or break by itself, so it is recommended to usually include it in a hordes:multiple function with a hordes:return function if you don't want anything else in the script to be processed.

Clone this wiki locally