Spawn Rules
Spawn Rules are a datapack feature that allow addons to modify spawning behaviour in a global way. Spawn Rules contain a set of rule components, and there are several component types to choose from. Spawn rules are loaded from the `spawn_rules` folder.
"weight": The weight rule component allows you to selectively modify the weight of spawn details as they are used. For example, you can make the weight of a Pikachu spawn in an area that is well lit to be multiplied by 20. {
"type": "weight", "spawnSelector": "v.spawn.pokemon.species == 'pikachu'", "contextSelector": "v.context.light > 8", "weight": "v.weight * 20"
"filter":
The filter rule component allows you to block or allow spawns. This is like adding a global rule against spawning. For example, you can make Pikachu unable to spawn in an area that is not well lit.
{
"type": "filter", "spawnSelector": "v.spawn.pokemon.species == 'pikachu'", "contextSelector": "v.context.light < 8", "allow": "false"
"location":
The location rule component allows you to block or allow locations to be considered for any spawning. This is more aggressive than the filter rule component because it cancels the spawning process much sooner. This is best used to create no-spawn zones.
{
"type": "location", "allow": "v.y > 100 || v.world.is_of('minecraft:overworld')"
Spawn Detail Properties Every spawn detail that is made available under the name "spawn" has properties that can be checked in your spawn rule components.
- "weight": The base weight of the spawn.
- "percentage": The base percentage spawn chance (usually null)
- "id": The unique ID of the spawn.
- "bucket": The bucket of the spawn.
- "width": The specified width required for spawning.
- "height": The specified height required for spawning.
- "context": The context type of the spawn.
- "labels": A list of label strings.
Pokémon Spawn Detail Properties
Pokémon spawn details have more properties than the general spawn detail.
- "pokemon": The specified Pokémon as a variable. This is what was specified in the file.
Pokémon Properties
Pokémon Properties referenced from MoLang expressions have many properties.
- "species": The species of the Pokémon, such as cobblemon:bulbasaur, if set.
- "level": The level of the Pokémon, if set.
- "shiny": True or false depending on if the Pokémon is explicitly marked as either. It can be null.
- "gender": The gender name, if set.
- "friendship": The friendship value of the Pokémon, if set.
Location properties
When using the "location" rule component, many variables are supplied.
- "x": The x coordinate being checked.
- "y": The y coordinate being checked.
- "z": The z coordinate being checked.
- "context": The context type being checked, such as "grounded" or "seafloor".
- "world": The world it's in. This contains two functions, is_of and is_in for checking the ID or if it fits a specific tag, respectively. For example, v.world.is_in('yourmod:your_world_tag').
- "dimension_type": The dimension it's in. This contains the same two functions as the "world" property.
Context properties
When using a context selector, a context will be added as a variable and it contains many variables.
- "light": The light level, from 0 to 15.
- "x": The x coordinate.
- "y": The y coordinate.
- "z": The z coordinate.
- "moon_phase": The phase of the moon, between 0 and 7 inclusive.
- "world": The world of the context, in the same format in the "location" properties.
- "biome": The biome of the context. This, like world and dimension type, contains two functions: is_of and is_in.
Example (weird) spawn rule:
{
"displayName": "Pikachu Daylight Multiplier - (Example file)", "enabled": "true", "components": [ { "type": "weight", "spawnSelector": "v.spawn.pokemon.species == 'pikachu'", "contextSelector": "v.context.light > 8", "weight": "v.weight * 20" }, { "type": "filter", "spawnSelector": "v.spawn.pokemon.species == 'pikachu'", "contextSelector": "v.context.light < 8", "allow": "false" }, { "type": "location", "allow": "v.y > 100 || v.world.is_of('minecraft:overworld')" } ]