Horde Scripts (Datapack support) - SmileycorpMC/The-Hordes GitHub Wiki
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 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 is the generic function hordes:multiple
which can be used with either.
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, this works with hordes:random
as well, so that all grouped functions are executed if the random condition passes.
Conditions are a set of comparisons, that will prevent a section of horde script from running if they are not met. Below is an example of a condition.
Example
{
"function": "hordes:set_spawntable",
"value": "hordes:mixed_mobs",
"conditions": [{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": ">=",
"value1": {
"name": "hordes:player_nbt",
"value": "XpLevel"
},
"value2": 15
}
}]
}
The above example will set the table to hordes:mixed_mobs
if the player triggering the horde has 15 or more levels.
Conditions are usually comprised of two elements, name
which is the name of the condition, which can be found below and value, which contains all the data related to the condition.
Below is a list of availiable conditions:
hordes:biome
is a condition that simply passes if the player is in a specified biome.
It takes a biome's registry name in string format as a value.
The below condition will pass if the player is in a swamp biome.
Example 1
{
"name": "hordes:biome",
"value": "minecraft:swamp"
}
1.4.0+
Example 2
{
"name": "hordes:biome",
"value": [
"#minecraft:is_ocean",
"#minecraft:is_river"
]
}
Example 3
{
"name": "hordes:biome",
"value": [
"#minecraft:is_badlands",
"minecraft:desert"
]
}
As of version 1.4.0+ biome tags can be used and biome conditions support a list of more than one allowed biome, and will pass if a player is in any of the supplied biomes or a biome listed on any of the supplied tags, biomes and tags can be mixed and matched.
hordes:day
is a condition that pass if the current day is greater than the specified day in an integer format.
The below condition will pass if the current day count is greater than 30.
Example
{
"name": "hordes:day",
"value": 30
}
hordes:local_difficulty
is a condition that pass if the local difficulty multiplier of the current chunk is above the specified number.
This multiplier is listed as clamped regional difficulty on the minecraft wiki and you can find more about it here..
Example
{
"name": "hordes:local_difficulty",
"value": 0.6
}
hordes:game_difficulty
is a condition that passes if the game difficulty is equal to the specified difficuly.
Acceped values are "easy", "medium", "hard" or numbers from 1-3 representing the same values in order.
The following examples are functionally identical:
Example1
{
"name": "hordes:game_difficulty",
"value": "hard"
}
Example2
{
"name": "hordes:game_difficulty",
"value": 3
}
hordes:random
will only pass at a random chance equal to the specified decimal, with a value 1 or more being guaranteed.
It takes a floating point value.
The below condition will pass with a roughly 30% chance.
Example
{
"name": "hordes:random",
"value": 0.3
}
hordes:advancement
will pass if a player triggering a horde event has a specific advancement.
The below example will pass if the player has the advancement for entering the nether.
Example
{
"name": "hordes:advancement",
"value": "minecraft:nether/root"
}
hordes:entity_type
will pass if the entity type of the event is equal to the specified entity type.
For Spawndata functions this will always be minecraft:player
for Spawn Event functions this will be the registry name of the entity the horde is trying to spawn.
The below example will replace 10% of spawned piglins in the horde with piglin brutes.
Example
{
"function": "hordes:set_entity_type",
"value": "minecraft:piglin_brute",
"conditions": [{
"name": "hordes:entity_type",
"value": "minecraft:piglin"
},
{
"name": "hordes:random",
"value": 0.1
}]
}
hordes:comparison
is probably the most useful condition, with the largest potential use cases, however it is one of the most complicated to use.
It takes two values and applying a specified comparison to them, if the comparison is true then the condition will pass.
Example
{
"name": "hordes:comparison",
"value": {
"type": "boolean",
"operation": "==",
"value1": {
"name": "hordes:player_nbt",
"value": "seenCredits"
},
"value2": true
}
}
This example as explained in an above section passes if the player has jumped into the end portal after defeating the ender dragon.
Comparison values are far more complicated than other conditions, taking 4 parameters as part of their value, broken down into three categories.
Types, operations and values.
The available types are byte
, short
, int
, long
, float
, double
, string
, boolean
.
The most commonly applicable types are int
which represents any whole number, float
which represents most decimal numbers, string
, which represents any text and boolean
which is simply just true or false.
Only string
values need to be surrounded by quoutation marks "
.
The other types are mostly applicable to nbt values, and should use the type specified by that nbt value.
Operations specify the type of comparison to use on the specified values.
==
or equals checks if both values are the same.
!=
or not equals, checks if both values are different.
Both of the above operations can be used for every data type, however those below are only for numbers byte
, short
, int
, long
, float
and double
.
<
or less than checks if value1 is less than value2.
>
or greater than checks if value1 is greater than value2.
<=
or less than or equal checks if value1 is less than value2, or if both values are the same.
>=
or greater than or equal checks if value1 is greater than value2, or if both values are the same.
For more information on values check the values page, here.
Example
{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": "<",
"value1": {
"name": "hordes:player_pos",
"value": "Y"
},
"value2": 60
}
}
hordes:not
inverts the value of a supplied condition, meaning the check will pass if the passed condition fails, and the check will fail if the supplied condition passes.
Example
{
"function": "hordes:set_spawntable",
"value": "hordes:mixed_mobs",
"conditions": {
"name": "hordes:not",
"value": {
"name": "hordes:biome",
"value": [
"#minecraft:is_ocean",
"#minecraft:is_river"
]
}
}
}
There are several logical conditions hordes:and
, hordes:nand
, hordes:or
, hordes:nor
and hordes:xor
, these take a list of other conditions and apply those conditions with the specified logical operation.
Example
{
"function": "hordes:set_spawntable",
"value": "hordes:mixed_mobs",
"conditions": {
"name": "hordes:or",
"value": [{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": ">=",
"value1": {
"name": "hordes:player_nbt",
"value": "XpLevel"
},
"value2": 15
}
}, {
"name": "hordes:biome",
"value": "minecraft:swamp"
}]
}
}
gamestages:gamestage
is mod integration with Game Stages and will only work if Game Stages is installed, remove ir from your scripts if it is not.
It will trigger if a player triggering a horde even has the specified game stage.
The below example will pass if the player has the gamestage "hard_mode"
.
Example
{
"name": "gamestages:gamestage",
"value": "hard_mode"
}