tutorial:biomes
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:biome [2019/07/14 21:47] – fix incorrect code :tiny_potato: valoeghese | tutorial:biomes [2022/08/16 20:50] (current) – DME mineblock11 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Adding a Biome ====== | + | DELETEME //**For versions 1.18 and beyond, biomes can be made completely using JSON, [[https:// |
- | ==== Introduction | + | ====== Adding Biomes [1.16.3] ====== |
- | + | There are 3 steps that are required | |
- | This wiki tutorial is focused on registering and adding biomes | + | |
- | + | ||
- | To add a biome, we will first need to create and register the biome, then add it to the world using helper methods from Fabric API. | + | |
- | This tutorial will go over: | + | |
* Creating a biome | * Creating a biome | ||
* Registering a biome | * Registering a biome | ||
* Adding a biome to a climate zone in the world | * Adding a biome to a climate zone in the world | ||
- | * Allowing the player to spawn in the biome | ||
- | We will also briefly go over other helpful | + | In this tutorial, we will add new biome called obsiland biome, whose surface is covered with obsidian. |
+ | |||
+ | Note that this tutorial depends on [[https:// | ||
+ | If the API doesn' | ||
==== Creating a Biome ==== | ==== Creating a Biome ==== | ||
- | To create a biome, | + | To create a biome, |
- | * The basic properties of the biome | + | Missing one property will likely cause the game to crash. |
- | * What features | + | It is recommended to look at vanilla biomes |
- | * What entities spawn here | + | |
- | We need to pass a '' | + | <code java> |
+ | public class ExampleMod implements ModInitializer { | ||
+ | // SurfaceBuilder defines how the surface | ||
+ | // We use custom surface builder for our biome to cover surface with obsidians. | ||
+ | private static final ConfiguredSurfaceBuilder< | ||
+ | .withConfig(new TernarySurfaceConfig( | ||
+ | Blocks.OBSIDIAN.getDefaultState(), | ||
+ | Blocks.DIRT.getDefaultState(), | ||
+ | Blocks.GRAVEL.getDefaultState())); | ||
- | Some important settings are depth (height), scale (hill size), and precipitation (weather) | + | private static final Biome OBSILAND = createObsiland(); |
- | <code java [enable_line_numbers=" | + | private static |
- | public class MyBiome extends | + | |
- | { | + | |
- | | + | // |
- | | + | // Vanilla configured features for biomes are defined in DefaultBiomeFeatures. |
- | | + | |
- | | + | |
- | } | + | |
- | </code> | + | |
- | We then need to specify the features and entities that spawn in the biome. Aside from some structures, trees, rocks, plants and custom entities, these are mostly the same for each biome. Vanilla configured features for biomes are defined through methods in '' | + | SpawnSettings.Builder spawnSettings = new SpawnSettings.Builder(); |
+ | | ||
+ | DefaultBiomeFeatures.addMonsters(spawnSettings, | ||
- | <code java [enable_line_numbers=" | + | GenerationSettings.Builder generationSettings |
- | public class MyBiome extends Biome | + | |
- | { | + | |
- | public MyBiome() | + | DefaultBiomeFeatures.addLandCarvers(generationSettings); |
- | { | + | DefaultBiomeFeatures.addDefaultLakes(generationSettings); |
- | super(new Biome.Settings().configureSurfaceBuilder(SurfaceBuilder.DEFAULT, | + | DefaultBiomeFeatures.addDungeons(generationSettings); |
- | + | DefaultBiomeFeatures.addMineables(generationSettings); | |
- | this.addStructureFeature(Feature.MINESHAFT, | + | DefaultBiomeFeatures.addDefaultOres(generationSettings); |
- | this.addStructureFeature(Feature.STRONGHOLD, | + | DefaultBiomeFeatures.addDefaultDisks(generationSettings); |
- | | + | DefaultBiomeFeatures.addSprings(generationSettings); |
- | | + | DefaultBiomeFeatures.addFrozenTopLayer(generationSettings); |
- | | + | |
- | | + | return |
- | DefaultBiomeFeatures.addDungeons(this); | + | .precipitation(Biome.Precipitation.RAIN) |
- | | + | .category(Biome.Category.NONE) |
- | DefaultBiomeFeatures.addDefaultFlowers(this); | + | .depth(0.125F) |
- | DefaultBiomeFeatures.addDefaultGrass(this); | + | |
- | | + | .temperature(0.8F) |
- | DefaultBiomeFeatures.addDefaultOres(this); | + | |
- | DefaultBiomeFeatures.addDefaultDisks(this); | + | .effects((new BiomeEffects.Builder()) |
- | | + | .waterColor(0x3f76e4) |
- | | + | |
- | DefaultBiomeFeatures.addFrozenTopLayer(this); | + | .fogColor(0xc0d8ff) |
- | | + | .skyColor(0x77adff) |
- | this.addSpawn(EntityCategory.CREATURE, | + | .build()) |
- | this.addSpawn(EntityCategory.CREATURE, | + | .spawnSettings(spawnSettings.build()) |
- | this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.COW, 8, 4, 4)); | + | .generationSettings(generationSettings.build()) |
- | this.addSpawn(EntityCategory.AMBIENT, new Biome.SpawnEntry(EntityType.BAT, 10, 8, 8)); | + | .build(); |
- | this.addSpawn(EntityCategory.MONSTER, | + | } |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.SLIME, | + | |
- | this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.ENDERMAN, | + | |
- | this.addSpawn(EntityCategory.MONSTER, | + | |
- | } | + | |
} | } | ||
</ | </ | ||
==== Registering Biomes ==== | ==== Registering Biomes ==== | ||
+ | We register our biome at the entrypoint '' | ||
+ | If you use your own surface builder, you will also have to register it. | ||
- | To register your biome, we will create a field which holds a biome instance, and add our biome to '' | + | <code java> |
+ | public class ExampleMod implements ModInitializer { | ||
+ | public static final RegistryKey< | ||
- | <code java [enable_line_numbers=" | + | @Override |
- | public | + | public |
- | { | + | Registry.register(BuiltinRegistries.CONFIGURED_SURFACE_BUILDER, new Identifier(" |
- | | + | Registry.register(BuiltinRegistries.BIOME, |
+ | } | ||
} | } | ||
</ | </ | ||
Line 89: | Line 89: | ||
You should also give your biome a language entry in your '' | You should also give your biome a language entry in your '' | ||
- | <code JavaScript src/ | + | <code JavaScript src/ |
{ | { | ||
- | " | + | " |
} | } | ||
</ | </ | ||
- | ==== Adding a biome to the world generator | + | ==== Adding a biome to a climate zone in the world ==== |
+ | We need to specify the climate to which the biome is added, the biome which we are adding, and the weight of the biome (a double value). | ||
+ | The weight is a measurement of the chance the biome has to spawn. | ||
+ | A higher weight corresponds to a higher chance for the biome to spawn, proportional to the weights of other biomes. | ||
+ | You may want to give your biome a higher weight during testing so you can find the biome more easily. | ||
+ | In this tutorial, we will add the custom biome to the TEMPERATE and COOL climates as an example. | ||
- | To make your biome spawn in the world, we will use the helper methods provided by the Fabric-Biomes API module. The code for this should ideally be run during mod initialization. | + | <code java> |
+ | public class ExampleMod implements ModInitializer { | ||
+ | @Override | ||
+ | public void onInitialize() { | ||
+ | [...] | ||
- | We need to specify the climate to which the biome is added, the biome which we are adding, and the weight of the biome (a double value). The weight is a measurement of the chance the biome has to spawn. A higher weight corresponds to a higher chance for the biome to spawn, proportional to the weights of other biomes. The Javadoc comments of each climate give the vanilla biome weights in each climate. You may want to give your biome a higher weight during testing so you can find the biome more easily. | + | |
- | + | OverworldBiomes.addContinentalBiome(OBSILAND_KEY, | |
- | In this tutorial, we will add the custom biome to the '' | + | } |
- | + | ||
- | <code java [enable_line_numbers=" | + | |
- | public class ExampleMod implements ModInitializer | + | |
- | { | + | |
- | @Override | + | |
- | public void onInitialize() | + | |
- | { | + | |
- | | + | |
- | OverworldBiomes.addContinentalBiome(OverworldClimate.COOL, TutorialBiomes.MY_BIOME, 2D); | + | |
- | } | + | |
} | } | ||
</ | </ | ||
- | To make the player able to spawn in the biome, we will use another method from the fabric-biomes api module: | + | ==== Result ==== |
- | + | ||
- | <code java [enable_line_numbers=" | + | |
- | FabricBiomes.addSpawnBiome(TutorialBiomes.MY_BIOME); | + | |
- | </ | + | |
**Congratulations!** Your biome should now be generating in the world! | **Congratulations!** Your biome should now be generating in the world! | ||
+ | You can use below command to find your biome in the world. | ||
- | ==== Other useful biome methods ==== | + | < |
- | + | / | |
- | There are other useful methods in the fabric biomes api that you may want to use, that add extra functionality. | + | |
- | + | ||
- | * **Setting the river biome** | + | |
- | + | ||
- | For example, setting your biome not to generate a river: | + | |
- | + | ||
- | < | + | |
- | OverworldBiomes.setRiverBiome(TutorialBiomes.MY_BIOME, | + | |
</ | </ | ||
- | * **Adding biome variants** | + | {{tutorial:obsiland.png}} |
- | + | ||
- | The third number is the chance (out of 1) for the biome to replaced with the specified variant. | + | |
- | For example, setting your biome to be a variant of plains, 33% of the time: | + | |
- | + | ||
- | <code java [enable_line_numbers=" | + | |
- | OverworldBiomes.addBiomeVariant(Biomes.PLAINS, | + | |
- | </ | + | |
- | + | ||
- | === The following methods take a weight value which specifies how common the biome is relative to other specified variants === | + | |
- | + | ||
- | * **Adding hills biomes** | + | |
- | + | ||
- | For example, setting mountains to be a " | + | |
- | + | ||
- | <code java [enable_line_numbers=" | + | |
- | OverworldBiomes.addHillsBiome(TutorialBiomes.MY_BIOME, | + | |
- | </ | + | |
- | + | ||
- | * **Adding biome edges** | + | |
- | + | ||
- | For example, making forest generate on the edge of your biome: | + | |
- | + | ||
- | <code java [enable_line_numbers=" | + | |
- | OverworldBiomes.addEdgeBiome(TutorialBiomes.MY_BIOME, | + | |
- | </ | + | |
- | + | ||
- | * **Adding biome shores / beaches** | + | |
- | + | ||
- | For example, making stone beach generate on the shore of your biome: | + | |
- | + | ||
- | <code java [enable_line_numbers=" | + | |
- | OverworldBiomes.addShoreBiome(TutorialBiomes.MY_BIOME, | + | |
- | </ | + | |
tutorial/biomes.1563140828.txt.gz · Last modified: 2019/07/14 21:47 by valoeghese