Biome API
The Biome API is a feature introduced in Bestium v3.0.0 and lives in the cz.jeme.bestium.api.inject.biome
package.
It allows you to define in which biomes, how often and in what quantities should your creature naturally spawn.
Configuring biome selection
Section titled “Configuring biome selection”To control in which biomes your entity may naturally spawn, you can define a SpawnRule
.
When the server starts, all registered biomes are passed into this function and the SpawnData
, definining
how often and in what quantities should the mob spawned, is injected to the biome.
You can implement your own custom rule (using a lambda), but there are already some builtin useful static methods:
-
never()
Doesn’t spawn your entity in any biomes. This is the default behavior when no rule is set. -
ifBiome(BiomeFilter, SpawnData)
Returns the providedSpawnData
for biomes where the biome filter tests positive. -
firstMatch(SpawnRule...)
Tries multiple spawn rules in order and returns the first one that successfully returnsSpawnData
. This is useful for combining logic.
You can set the spawn rule of an EntityInjection.Builder
using setSpawnRule(SpawnRule).
A BiomeFilter
is a predicate that checks whether a given biome matches a certain condition. It returns true
if the condition is met, and false
otherwise.
You can implement your own custom rule (using a lambda), but there are already some builtin static methods:
Logical operations
Section titled “Logical operations”All filters must pass.
At least one filter must pass.
Inverts the filter result.
Other useful methods
Section titled “Other useful methods”Filters biomes based on their base temperature. Unlike normal temperature, base temperature is a static value defined in biome’s definition.
You can use BiomeTemperature
to access predefined ranges: COLD
, TEMPERATE
, WARM
.
Filters biomes by tag (for example minecraft:is_savanna
). Tags group related biomes, for a full list,
see Minecraft Wiki - Biome tag.
key(Key)
and keys(...)
Section titled “key(Key) and keys(...)”Filters by exact biome key (for example minecraft:savanna_plateau
). For a full list of vanilla biome keys,
see Minecraft Wiki - Biome IDs.
Convenience Filters
Section titled “Convenience Filters”Matches biomes tagged with minecraft:is_overworld
.
Matches biomes tagged with minecraft:is_nether
.
Matches biomes tagged with minecraft:is_end
.
Example
Section titled “Example”Example EntityInjection.Builder
spawn configuration for our capybara may look like this:
EntityInjection.builder(...)....setSpawnRule( SpawnRule.ifBiome( BiomeFilter.tag(Key.key("minecraft:is_river")), SpawnData(3, 1, 4) ))
EntityInjection.builder(...)....setSpawnRule( SpawnRule.ifBiome( BiomeFilter.tag(Key.key("minecraft:is_river")), new SpawnData(3, 1, 4) ))