-
Notifications
You must be signed in to change notification settings - Fork 11
Horde Scripts ‐ Values
Values are potentially the most complicated parts of horde scripts and have several forms.
They can be used anywhere where a value property is expected, this also applies for the value1 and value2 expected by hordes:comparison conditions and some of the below values.
The first type of value is a static value, which is a value that doesn't change and is specified in the condition.
Static values are used most of the time when a function or condition is expecting a value
In the below example "hordes:default" is a static value.
Example 1
{
"function": "hordes:set_spawntable",
"value": "hordes:default"
"conditions": []
}
In the following example 15 is a static value.
Example 2
{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": ">=",
"value1": {
"name": "hordes:player_nbt",
"value": "XpLevel"
},
"value2": 15
}
}
Nbt values search their associated nbt data structure for a specified value, in the above example XpLevel which corresponds to a player's current level.
hordes:level_nbt will search world data, hordes:player_nbt will search player nbt and hordes:entity_nbt will search entity nbt for spawn event functions, and player nbt otherwise.
Each nbt element in the compound structure should separated by . for defining large structures, and the value will search for any values, with the specified name or a compound with a matching value in a field called Name.
I'd recommend using an external program like nbt explorer and/or the minecraft wiki's nbt data pages to figure out which values you are trying to target.
Example
{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": ">=",
"value1": {
"name": "hordes:player_nbt",
"value": "XpLevel"
},
"value2": 15
}
}
Position values get the entity coordiate value on the specified axis.
hordes:player_pos gets the player's position, hordes:entity_pos gets the entities position for spawn entity events and the player's position otherwise.
It will get the entities's block position if the type int is used, or the entities's actual position if any decimal type is used.
The following example shows a comparison condition that will pass if a player is below y 60.
Example
{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": "<",
"value1": {
"name": "hordes:player_pos",
"value": "y"
},
"value2": 60
}
}
hordes:day gets the current horde event day, this is not the same as the game day and only reflects the horde event's internal day counter. (Note this is usually synced to player playtime unless the hordeEventByPlayerTime option is set to false in the config)
The following example shows a comparison condition that will pass if the event day is 20.
Example
{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": "==",
"value1": {
"name": "hordes:day"
},
"value2": 20
}
}
hordes:spawn_table gets the current horde event spawntable name.
The following example shows a comparison condition that will pass if the current event is set to use the hordes:illagers table.
Example
{
"name": "hordes:comparison",
"value": {
"type": "string",
"operation": "==",
"value1": {
"name": "hordes:spawn_table"
},
"value2": "hordes:illagers"
}
}
hordes:get_variable gets a variable that has been saved to the current executing event by the hordes:set_variable function.
Example
{
"name": "hordes:comparison",
"value": {
"type": "int",
"operation": "==",
"value1": {
"name": "hordes:get_variable",
"value": "phase"
},
"value2": 3
}
}
hordes:weighted_random gets a random value from a set list using weighting, similar to how horde tables or vanilla loot tables work, higher numbers are more likely to get chosen.
Example
{
"function": "hordes:set_spawntable",
"value": {
"name": "hordes:weighted_random",
"value": [
{
"value": "hordes:default",
"weight": 5
},
{
"value": "hordes:skeletons",
"weight": 3
},
{
"value": "hordes:illagers",
"weight": 1
}
]
},
"conditions": []
}
Unary operation values apply a specified function to a given value.
Example 1
{
"value": {
"name": "hordes:sin",
"value": [
"name": "hordes:day"
]
}
}
Example 2
{
"value": {
"name": "hordes:abs",
"value": -5
}
}
Example 3
{
"value": {
"name": "hordes:floor",
"value": {
"name": "hordes:entity_nbt",
"value": "Attributes.minecraft:generic.attack_damage.Base"
}
}
}
The following is a list of all available unary operations:
Table
| Name | Data Type | Function |
|---|---|---|
| hordes:random | int | Returns a positive integer between 0 (inclusive) and the specified number (exclusive). |
| hordes:abs | any number | Returns the absolute value of the given number, making it positive if it was negative before. |
| hordes:round | any number | Rounds the number to the nearest integer. |
| hordes:floor | any number | Rounds the number to the nearest integer below it. |
| hordes:ceil | any number | Rounds the number to the nearest integer above it. |
| hordes:truncate | any number | Discards all decimal places from the number. (Acts as floor for positive numbers and ceil for negative ones) |
| hordes:log | any number | Returns the natural logarithm of the given number. |
| hordes:sin | any number | Returns the sine of the given number. |
| hordes:cos | any number | Returns the cosine of the given number. |
| hordes:tan | any number | Returns the tangent of the given number. |
| hordes:arcsin | any number | Returns the inverse sine of the given number. |
| hordes:arccos | any number | Returns the inverse cosine of the given number. |
| hordes:arctan | any number | Returns the inverse tangent of the given number. |
| hordes:sinh | any number | Returns the hyperbolic sine of the given number. |
| hordes:cosh | any number | Returns the hyperbolic cosine of the given number. |
| hordes:tanh | any number | Returns the hyperbolic tangent of the given number. |
| hordes:bitwise_not | int | Converts the number into it’s binary representation, inverts the bits, then converts the new number back into an integer. |
Binary operation values apply a specified function to two given values.
Example 1
{
"value": {
"name": "hordes:add",
"value1": {
"name": "hordes:get_variable",
"value": "phase"
},
"value2": 1
}
}
Example 2
{
"value": {
"name": "hordes:mod",
"value1": {
"name": "hordes:level_nbt",
"value": "Time"
},
"value2": 24000
}
}
The following is a list of all available unary operations:
Table
| Name | Data Type | Function |
|---|---|---|
| hordes:add | any number | Adds two values together. |
| hordes:minus | any number | Subtracts the second value from the first value. |
| hordes:multiply | any number | Multiplies two values together. |
| hordes:divide | any number | Divides the first value by the second value. |
| hordes:mod | any number | Returns the remainder of the first value divided by the second value. |
| hordes:pow | any number | Returns the first value multiplied by itself an amount of times equal to the second value. |
| hordes:bitwise_and | int | Returns a new number made of the binary bits between the two numbers that are the same. |
| hordes:bitwise_or | int | Returns a new number made of the binary bits that are present in either number. |
| hordes:bitwise_xor | int | Returns a new number made of the binary bits that are present in one number but not both. |
| hordes:left_shift | int | Shifts the first number’s binary bits left by the second number, adding zeroes to the end. |
| hordes:right_shift | int | Shifts the first number’s binary bits right by the second number, discarding the rightmost bits and copying the leftmost bit. |
| hordes:unsigned_right_shift | int | Shifts the first number’s binary bits right by the second number, discarding the rightmost bits and replacing the leftmost bits with zeroes. |