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
Last revisionBoth sides next revision
tutorial:biome [2020/09/04 20:42] siglongtutorial:biomes [2022/02/17 12:34] – typo redgrapefruit
Line 1: Line 1:
-====== Adding a Biome ====== +====== Adding Biomes [1.16.3] ======
-**NOTE:** There is [[https://github.com/FabricMC/fabric/pull/1036|a ongoing pull request on Fabric API]] that adds biome API for 1.16.2. +
-Please use this tutorial as a workaround until it gets merged. +
- +
-==== Introduction ==== +
 There are 3 steps that are required to add a biome to the world. There are 3 steps that are required to add a biome to the world.
   * Creating a biome   * Creating a biome
Line 10: Line 5:
   * Adding a biome to a climate zone in the world   * Adding a biome to a climate zone in the world
  
-In this tutorial, we will add new biome called obsiland biome, whose surface is covered with obsidians.+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 ====
Line 22: Line 20:
   // We use custom surface builder for our biome to cover surface with obsidians.   // We use custom surface builder for our biome to cover surface with obsidians.
   private static final ConfiguredSurfaceBuilder<TernarySurfaceConfig> OBSIDIAN_SURFACE_BUILDER = SurfaceBuilder.DEFAULT   private static final ConfiguredSurfaceBuilder<TernarySurfaceConfig> OBSIDIAN_SURFACE_BUILDER = SurfaceBuilder.DEFAULT
-    .method_30478(new TernarySurfaceConfig(+    .withConfig(new TernarySurfaceConfig(
       Blocks.OBSIDIAN.getDefaultState(),       Blocks.OBSIDIAN.getDefaultState(),
       Blocks.DIRT.getDefaultState(),       Blocks.DIRT.getDefaultState(),
Line 82: Line 80:
   public void onInitialize() {   public void onInitialize() {
     Registry.register(BuiltinRegistries.CONFIGURED_SURFACE_BUILDER, new Identifier("tutorial", "obsidian"), OBSIDIAN_SURFACE_BUILDER);     Registry.register(BuiltinRegistries.CONFIGURED_SURFACE_BUILDER, new Identifier("tutorial", "obsidian"), OBSIDIAN_SURFACE_BUILDER);
- 
     Registry.register(BuiltinRegistries.BIOME, OBSILAND_KEY.getValue(), OBSILAND);     Registry.register(BuiltinRegistries.BIOME, OBSILAND_KEY.getValue(), OBSILAND);
-    BuiltinBiomesAccessor.getRawIdMap().put(BuiltinRegistries.BIOME.getRawId(OBSILAND), OBSILAND_KEY); 
-  } 
-} 
-</code> 
- 
-<code java> 
-@Mixin(BuiltinBiomes.class) 
-public interface BuiltinBiomesAccessor { 
-  @Accessor("BY_RAW_ID") 
-  public static Int2ObjectMap<RegistryKey<Biome>> getRawIdMap() { 
-    throw new AssertionError(); 
   }   }
 } }
Line 108: Line 94:
  
 ==== Adding a biome to a climate zone in the world ==== ==== Adding a biome to a climate zone in the world ====
-The vanilla biomes used in the overworld is defined in ''VanillaLayeredBiomeSource.BIOMES''+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). 
-We have to add our biome to it first.+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.
  
 <code java> <code java>
Line 117: Line 106:
     [...]     [...]
  
-    // We have to copy existing List because it is immutable. +    OverworldBiomes.addContinentalBiome(OBSILAND_KEY, OverworldClimate.TEMPERATE, 2D); 
-    List<RegistryKey<Biome>> biomes = new ArrayList<>(VanillaLayeredBiomeSourceAccessor.getBiomes()); +    OverworldBiomes.addContinentalBiome(OBSILAND_KEY, OverworldClimate.COOL2D);
-    biomes.add(OBSILAND_KEY); +
-    VanillaLayeredBiomeSourceAccessor.setBiomes(biomes); +
-  } +
-+
-</code> +
- +
-<code java> +
-@Mixin(VanillaLayeredBiomeSource.class) +
-public interface VanillaLayeredBiomeSourceAccessor { +
-  @Accessor("BIOMES"+
-  public static List<RegistryKey<Biome>> getBiomes() { +
-    throw new AssertionError(); +
-  } +
- +
-  @Accessor("BIOMES"+
-  public static void setBiomes(List<RegistryKey<Biome>> biomes) { +
-    throw new AssertionError(); +
-  } +
-+
-</code> +
- +
-Secondlywe need to specify the climate to which the biome is added. +
-In this tutorialwe will add the custom biome to the temperate climate as an example. +
-We modify ''SetBaseBiomesLayer.TEMPERATE_BIOMES'' to accomplish this. +
- +
-<code java> +
-public class ExampleMod implements ModInitializer { +
-  @Override +
-  public void onInitialize() { +
-    [...] +
- +
-    // SetBaseBiomesLayer.TEMPERATE_BIOMES is an array of raw biome IDs. +
-    // We have to get the raw id of our biome and append it to TEMPERATE_BIOMES. +
-    SetBaseBiomesLayerAccessor.setTemperateBiomes( +
-      ArrayUtils.add(SetBaseBiomesLayerAccessor.getTemperateBiomes(), BuiltinRegistries.BIOME.getRawId(OBSILAND))); +
-  } +
-+
-</code> +
- +
-<code java> +
-@Mixin(SetBaseBiomesLayer.class) +
-public interface SetBaseBiomesLayerAccessor { +
-  @Accessor("TEMPERATE_BIOMES"+
-  public static int[] getTemperateBiomes() { +
-    throw new AssertionError(); +
-  } +
- +
-  @Accessor("TEMPERATE_BIOMES"+
-  public static void setTemperateBiomes(int[] biomes) { +
-    throw new AssertionError();+
   }   }
 } }
Line 182: Line 121:
  
 {{tutorial:obsiland.png}} {{tutorial:obsiland.png}}
 +
tutorial/biomes.txt · Last modified: 2022/08/16 20:50 by mineblock11