Creating Custom Biomes
Custom biomes
Section titled “Custom biomes”Custom biomes are the gateway to BiomesAPI. To do anything in BiomesAPI, you’ll need to make a custom biome first!
// A biome of white fog, folia, water, grass with a black sky and water fog colorCustomBiome customBiome = CustomBiome.builder() .resourceKey(BiomeResourceKey.of("test", "custombiome")) // Make sure this is unique! .settings(BiomeSettings.defaultSettings()) .fogColor("#FFFFFF") .foliageColor("#F5F2EB") .skyColor("#000000") .waterColor("#F5F2EB") .waterFogColor("#000000") // Water fog is what the player sees while swimming! .grassColor("#F5F2EB") .build();
// After creating your biome, you'll need to register it. customBiome.register();You have now created your very own custom biome! Your biome is now in the Minecraft server’s registry and is ready to be used. Let’s use the BiomeSetter API to get started with that.
Using the BiomeSetter
Section titled “Using the BiomeSetter”The BiomeSetter is how you tell BiomesAPI where to put your custom biomes. To set a custom biome somewhere, you’ll need
a reference to it from somewhere. There are many strategies to doing this. In the tutorial below I will be getting a reference
to my custom biome from the BiomesAPI BiomeHandler which acts similar to a registry for custom biomes.
// I'm using the BlockBreakEvent to get an easy reference to a player, but you can do this any way you'd like!@EventHandlerpublic void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer();
CustomBiome customBiome = BiomeHandler.getBiome(BiomeResourceKey.of("test", "custombiome"));
if (customBiome == null) { player.sendMessage("Custom biome not found!"); return; }
// Change all loaded chunks in the world to your custom biome World world = player.getWorld(); for (Chunk loadedChunk : world.getLoadedChunks()) { // Include the `true` parameter to immediately update the biome for every player! BiomeSetter.of().setChunkBiome(loadedChunk, customBiome, true); }}Another example changing a singular block to your biome:
@EventHandlerpublic void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); Block block = event.getBlock(); CustomBiome customBiome = BiomeHandler.getBiome(BiomeResourceKey.of("test", "custombiome")); if (customBiome == null) { player.sendMessage("Custom biome not found!"); return; }
// Change the biome of the block the player broke BiomeSetter.of().setBlockBiome(block, customBiome, true);}You have now successfully set your custom biome in the world! You can use the BiomeSetter API to set biomes on blocks, chunks, or regions. TODO: See the BiomeSetter javadocs for more information!