User Tools

Site Tools


tutorial:biomes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:biome [2019/07/14 21:47] – fix incorrect code :tiny_potato: valoeghesetutorial: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://minecraft.fandom.com/wiki/Biome/JSON_format|take a look the Minecraft Wikia for more information.]]**.//
  
-==== Introduction ==== +====== Adding Biomes [1.16.3] ====== 
- +There are 3 steps that are required to add a biome to the world.
-This wiki tutorial is focused on registering and adding biomes to the world. +
- +
-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 biome-adding methods in the api.+In this tutorial, we will add new biome called obsiland biome, whose surface is covered with obsidian. 
 + 
 +Note that this tutorial depends on [[https://github.com/FabricMC/fabric/pull/1053|the Biome API in Fabric API]] which is marked as experimental. 
 +If the API doesn't work, consider using [[?rev=1602901100|the mixin version]].
  
 ==== Creating a Biome ==== ==== Creating a Biome ====
-To create a biome, create a class that extends Biome. This is the base class that holds biome information, and all vanilla biomes extend thisThis class defines: +To create a biome, use ''Biome.Builder'' and configure properties
-  * The basic properties of the biome +Missing one property will likely cause the game to crash. 
-  * What features (trees, plants and structuresgenerate here +It is recommended to look at vanilla biomes (created in ''DefaultBiomeCreator''as examples.
-  * What entities spawn here+
  
-We need to pass a ''Biome.Settings'' instance with **all** the basic properties of the biome to the super constructorMissing one property will likely cause the game to crashIt is recommended to look at vanilla biomes such as ''MountainsBiome'' and ''ForestBiome'' as examples.+<code java> 
 +public class ExampleMod implements ModInitializer { 
 +  // SurfaceBuilder defines how the surface of your biome looks. 
 +  // We use custom surface builder for our biome to cover surface with obsidians. 
 +  private static final ConfiguredSurfaceBuilder<TernarySurfaceConfig> OBSIDIAN_SURFACE_BUILDER = SurfaceBuilder.DEFAULT 
 +    .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="true"]> +  private static Biome createObsiland() 
-public class MyBiome extends Biome +    // We specify what entities spawn and what features generate in the biome. 
-+    // Aside from some structures, trees, rocks, plants and 
-    public MyBiome() +    //   custom entitiesthese are mostly the same for each biome
-    { +    // Vanilla configured features for biomes are defined in DefaultBiomeFeatures.
-        super(new Biome.Settings().configureSurfaceBuilder(SurfaceBuilder.DEFAULTSurfaceBuilder.GRASS_CONFIG).precipitation(Biome.Precipitation.RAIN).category(Biome.Category.PLAINS).depth(0.24F).scale(0.2F).temperature(0.6F).downfall(0.7F).waterColor(4159204).waterFogColor(329011).parent((String)null)); +
-    +
-+
-</code>+
  
-We then need to specify the features and entities that spawn in the biomeAside from some structures, trees, rocks, plants and custom entities, these are mostly the same for each biomeVanilla configured features for biomes are defined through methods in ''DefaultBiomeFeatures''.+    SpawnSettings.Builder spawnSettings = new SpawnSettings.Builder(); 
 +    DefaultBiomeFeatures.addFarmAnimals(spawnSettings); 
 +    DefaultBiomeFeatures.addMonsters(spawnSettings, 95, 5, 100);
  
-<code java [enable_line_numbers="true"]> +    GenerationSettings.Builder generationSettings = new GenerationSettings.Builder(); 
-public class MyBiome extends Biome +    generationSettings.surfaceBuilder(OBSIDIAN_SURFACE_BUILDER); 
-+    DefaultBiomeFeatures.addDefaultUndergroundStructures(generationSettings); 
-    public MyBiome() +    DefaultBiomeFeatures.addLandCarvers(generationSettings); 
-    { +    DefaultBiomeFeatures.addDefaultLakes(generationSettings); 
-        super(new Biome.Settings().configureSurfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_CONFIG).precipitation(Biome.Precipitation.RAIN).category(Biome.Category.PLAINS).depth(0.24F).scale(0.2F).temperature(0.6F).downfall(0.7F).waterColor(4159204).waterFogColor(329011).parent((String)null)); +    DefaultBiomeFeatures.addDungeons(generationSettings); 
-         +    DefaultBiomeFeatures.addMineables(generationSettings); 
-        this.addStructureFeature(Feature.MINESHAFT, new MineshaftFeatureConfig(0.004D, MineshaftFeature.Type.NORMAL)); +    DefaultBiomeFeatures.addDefaultOres(generationSettings); 
-        this.addStructureFeature(Feature.STRONGHOLD, FeatureConfig.DEFAULT); +    DefaultBiomeFeatures.addDefaultDisks(generationSettings); 
-        this.addStructureFeature(Feature.VILLAGE, new VillageFeatureConfig("village/plains/town_centers", 6)); +    DefaultBiomeFeatures.addSprings(generationSettings); 
-        DefaultBiomeFeatures.addLandCarvers(this); +    DefaultBiomeFeatures.addFrozenTopLayer(generationSettings); 
-        DefaultBiomeFeatures.addDefaultStructures(this); + 
-        DefaultBiomeFeatures.addDefaultLakes(this); +    return (new Biome.Builder()) 
-        DefaultBiomeFeatures.addDungeons(this); +      .precipitation(Biome.Precipitation.RAIN
-        DefaultBiomeFeatures.addExtraMountainTrees(this); +      .category(Biome.Category.NONE
-        DefaultBiomeFeatures.addDefaultFlowers(this); +      .depth(0.125F) 
-        DefaultBiomeFeatures.addDefaultGrass(this); +      .scale(0.05F
-        DefaultBiomeFeatures.addMineables(this); +      .temperature(0.8F) 
-        DefaultBiomeFeatures.addDefaultOres(this); +      .downfall(0.4F
-        DefaultBiomeFeatures.addDefaultDisks(this); +      .effects((new BiomeEffects.Builder()) 
-        DefaultBiomeFeatures.addDefaultVegetation(this); +        .waterColor(0x3f76e4) 
-        DefaultBiomeFeatures.addSprings(this); +        .waterFogColor(0x050533
-        DefaultBiomeFeatures.addFrozenTopLayer(this); +        .fogColor(0xc0d8ff
-        this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.SHEEP, 12, 4, 4)); +        .skyColor(0x77adff
-        this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.PIG, 10, 4, 4)); +        .build()) 
-        this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.CHICKEN, 10, 4, 4)); +      .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, new Biome.SpawnEntry(EntityType.SPIDER, 100, 4, 4)); +  }
-        this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.ZOMBIE, 95, 4, 4)); +
-        this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1)); +
-        this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.SKELETON, 100, 4, 4)); +
-        this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.CREEPER, 100, 4, 4)); +
-        this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.SLIME, 100, 4, 4)); +
-        this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.ENDERMAN, 10, 1, 4)); +
-        this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.WITCH, 5, 1, 1)); +
-    }+
 } }
 </code> </code>
  
 ==== Registering Biomes ==== ==== Registering Biomes ====
 +We register our biome at the entrypoint ''onInitialize''.
 +If you use your own surface builder, you will also have to register it.
  
-To register your biomewe will create a field which holds a biome instanceand add our biome to ''Registry.BIOME''. It is recommended to make a class to hold your biome objects.+<code java> 
 +public class ExampleMod implements ModInitializer { 
 +  public static final RegistryKey<Biome> OBSILAND_KEY = RegistryKey.of(Registry.BIOME_KEYnew Identifier("tutorial""obsiland"));
  
-<code java [enable_line_numbers="true"]> +  @Override 
-public class TutorialBiomes +  public void onInitialize() 
-+    Registry.register(BuiltinRegistries.CONFIGURED_SURFACE_BUILDER, new Identifier("tutorial", "obsidian"), OBSIDIAN_SURFACE_BUILDER); 
-    public static final Biome MY_BIOME = Registry.register(Registry.BIOME, new Identifier("tutorial", "my_biome"), new MyBiome());+    Registry.register(BuiltinRegistries.BIOME, OBSILAND_KEY.getValue(), OBSILAND); 
 +  }
 } }
 </code> </code>
Line 89: Line 89:
 You should also give your biome a language entry in your ''en_us.json'' file: You should also give your biome a language entry in your ''en_us.json'' file:
  
-<code JavaScript src/main/resources/assets/tutorial/lang/en_us.json>+<code JavaScript src/main/resources/assets/modid/lang/en_us.json>
 { {
-  "biome.tutorial.my_biome": "My Biome"+  "biome.tutorial.obsiland": "Obsiland"
 } }
 </code> </code>
  
-==== 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, OverworldClimate.TEMPERATE, 2D); 
- +    OverworldBiomes.addContinentalBiome(OBSILAND_KEY, OverworldClimate.COOL, 2D); 
-In this tutorial, we will add the custom biome to the ''TEMPERATE'' and ''COOL'' climates as an example: +  }
- +
-<code java [enable_line_numbers="true"]> +
-public class ExampleMod implements ModInitializer +
-+
-    @Override +
-    public void onInitialize() +
-    { +
-        OverworldBiomes.addContinentalBiome(OverworldClimate.TEMPERATE, TutorialBiomes.MY_BIOME, 2D); +
-        OverworldBiomes.addContinentalBiome(OverworldClimate.COOL, TutorialBiomes.MY_BIOME, 2D); +
-    }+
 } }
 </code> </code>
  
-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="false"]> +
-FabricBiomes.addSpawnBiome(TutorialBiomes.MY_BIOME); +
-</code> +
 **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 ==== +<code> 
- +/locatebiome tutorial:obsiland
-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: +
- +
-<code java [enable_line_numbers="false"]+
-OverworldBiomes.setRiverBiome(TutorialBiomes.MY_BIOME, null);+
 </code> </code>
  
-  * **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="false"]> +
-OverworldBiomes.addBiomeVariant(Biomes.PLAINS, TutorialBiomes.MY_BIOME, 0.33); +
-</code> +
- +
-=== 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 "hills" variant of your biome:  +
- +
-<code java [enable_line_numbers="false"]> +
-OverworldBiomes.addHillsBiome(TutorialBiomes.MY_BIOME, Biomes.MOUNTAINS, 1); +
-</code> +
- +
-  * **Adding biome edges** +
- +
-For example, making forest generate on the edge of your biome: +
- +
-<code java [enable_line_numbers="false"]> +
-OverworldBiomes.addEdgeBiome(TutorialBiomes.MY_BIOME, Biomes.FOREST, 1); +
-</code> +
- +
-  * **Adding biome shores / beaches** +
- +
-For example, making stone beach generate on the shore of your biome: +
- +
-<code java [enable_line_numbers="false"]> +
-OverworldBiomes.addShoreBiome(TutorialBiomes.MY_BIOME, Biomes.STONE_BEACH, 1); +
-</code>+
  
tutorial/biomes.1563140828.txt.gz · Last modified: 2019/07/14 21:47 by valoeghese