Adding Biomes to Dimensions
Adding your biomes to dimensions is an important step in bringing together your custom world generation.
If you want to use your world generation in an existing world such as minecraft:overworld, then this is a necessary step.
The DimensionEditor and the
Composer.DATAPACK version of the
BootstrapBiomeRegistry both have the
ability to add or replace biomes in dimensions.
Using the DimensionEditor
Section titled “Using the DimensionEditor”The DimensionEditor, in its current state,
injects and adds biomes to dimensions entirely transiently. This means that if your biome is never saved to the dimension
and the server will always be able to load the Minecraft world without your biome being registered.
Use the dimension editor if:
- You want to add or replace biomes in dimensions during the runtime of your plugin.
- You expect your plugin not always being present on a server, or want Minecraft worlds to be able to load without your biome being registered.
Example Usage
Section titled “Example Usage”import me.outspending.biomesapi.biome.CustomBiome;
import me.outspending.biomesapi.registry.ResourceKey;
import me.outspending.biomesapi.registry.dimension.DimensionEditor;
import me.outspending.biomesapi.wrapper.worldgen.BiomeGenerationSettings;
import me.outspending.biomesapi.wrapper.worldgen.GenerationStep;
import me.outspending.biomesapi.wrapper.worldgen.placement.PlacedFeatures;
import org.bukkit.plugin.java.JavaPlugin;
public class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable() {
BiomeGenerationSettings generation = BiomeGenerationSettings.builder()
.addFeature(GenerationStep.VEGETAL_DECORATION, PlacedFeatures.TREES_PLAINS)
.addFeature(GenerationStep.VEGETAL_DECORATION, PlacedFeatures.FALLEN_OAK_TREE)
.build();
ResourceKey myBiomeKey = ResourceKey.of("example", "my_biome");
CustomBiome.builder(myBiomeKey)
.fogColor("#DB00FD")
.skyColor("#2F46FF")
.waterColor("#00FFD0")
.grassColor("#D1D13A")
.foliageColor("#FF6A00")
.setGenerationSettings(generation)
.register();
DimensionEditor dimensionEditor = DimensionEditor.create();
ResourceKey overworldKey = ResourceKey.of("minecraft", "overworld");
ResourceKey plainsKey = ResourceKey.of("minecraft", "plains");
dimensionEditor.replaceInDimension(overworldKey, plainsKey, myBiomeKey);
dimensionEditor.apply(); // Applies to all loaded worlds
}
} When to use the BootstrapBiomeRegistry (Composer.DATAPACK)
Section titled “When to use the BootstrapBiomeRegistry (Composer.DATAPACK)”The BootstrapBiomeRegistry version of the
Composer.DATAPACK adds or replaces biomes in dimensions during the Bootstrap phase of your plugin’s lifecycle.
This means that if your biome is not present, the world will fail to load and will not be able to load unless your biome becomes present
or manual modifications are made to that world’s .dat files.
If you want BiomesAPI to mimic a normal datapack or you anticipate and want your biome to always be present on a given server, then this is the option for you.
Example Usage
Section titled “Example Usage”import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
import me.outspending.biomesapi.biome.CustomBiome;
import me.outspending.biomesapi.registry.ResourceKey;
import me.outspending.biomesapi.registry.bootstrap.BootstrapBiomeRegistry;
import me.outspending.biomesapi.registry.bootstrap.Composer;
import me.outspending.biomesapi.wrapper.worldgen.BiomeGenerationSettings;
import me.outspending.biomesapi.wrapper.worldgen.GenerationStep;
import me.outspending.biomesapi.wrapper.worldgen.placement.PlacedFeatures;
public class ExampleBootstrapper implements PluginBootstrap {
@Override
public void bootstrap(BootstrapContext context) {
// This must use the 'DATAPACK' composer!
BootstrapBiomeRegistry registry = BootstrapBiomeRegistry.compose(context, Composer.DATAPACK);
BiomeGenerationSettings generation = BiomeGenerationSettings.builder()
.addFeature(GenerationStep.VEGETAL_DECORATION, PlacedFeatures.TREES_PLAINS)
.addFeature(GenerationStep.VEGETAL_DECORATION, PlacedFeatures.FALLEN_OAK_TREE)
.build();
ResourceKey myBiomeKey = ResourceKey.of("example", "my_biome");
registry.queue(
CustomBiome.builder(myBiomeKey)
.fogColor("#DB00FD")
.skyColor("#2F46FF")
.waterColor("#00FFD0")
.grassColor("#D1D13A")
.foliageColor("#FF6A00")
.setGenerationSettings(generation)
.build()
);
ResourceKey overworldKey = ResourceKey.of("minecraft", "overworld");
ResourceKey plainsKey = ResourceKey.of("minecraft", "plains");
registry.replaceInDimension(overworldKey, plainsKey, myBiomeKey); // Adds this to BiomesAPI's generated transient datapack
}
}