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
Next revisionBoth sides next revision
tutorial:biome [2020/09/04 19:50] – Get rid of access wideners siglongtutorial:biomes [2020/10/17 02:18] – updated mappings hydos
Line 1: Line 1:
-====== Adding a Biome ======+====== Adding Biomes ======
 **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. **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.
-Read this tutorial as a workaround until it gets merged.+Please use this tutorial as a workaround until it gets merged.
  
 ==== Introduction ==== ==== 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 22: Line 21:
   // 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 108: Line 107:
  
 ==== 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 ''VanillaLayeredBiomeSource''+The vanilla biomes used in the overworld is defined in ''VanillaLayeredBiomeSource.BIOMES''
-We have to add our biome to ''VanillaLayeredBiomeSource'' first.+We have to add our biome to it first. 
 + 
 +<code java> 
 +public class ExampleMod implements ModInitializer { 
 +  @Override 
 +  public void onInitialize() { 
 +    [...] 
 + 
 +    // We have to copy existing List because it is immutable. 
 +    List<RegistryKey<Biome>> biomes = new ArrayList<>(VanillaLayeredBiomeSourceAccessor.getBiomes()); 
 +    biomes.add(OBSILAND_KEY); 
 +    VanillaLayeredBiomeSourceAccessor.setBiomes(biomes); 
 +  } 
 +
 +</code>
  
 <code java> <code java>
 @Mixin(VanillaLayeredBiomeSource.class) @Mixin(VanillaLayeredBiomeSource.class)
-public class VanillaLayeredBiomeSourceMixin +public interface VanillaLayeredBiomeSourceAccessor 
-  @ModifyArgs(method = "<init>(JZZLnet/minecraft/util/registry/Registry;)V", at = @At(value = "INVOKE", target = "net/minecraft/world/biome/source/BiomeSource.<init>(Ljava/util/stream/Stream;)V")+  @Accessor("BIOMES"
-  private static void addOverworldBiomes(Args args, long seed, boolean legacyBiomeInitLayer, boolean largeBiomes, +  public static List<RegistryKey<Biome>getBiomes() { 
-      Registry<Biome> biomeRegistry) { +    throw new AssertionError(); 
-    Stream<Supplier<Biome>> biomes = args.get(0); +  } 
-    biomes = Stream.concat(biomes, Stream.of(() -> biomeRegistry.get(ExampleMod.OBSILAND_KEY))); + 
-    args.set(0, biomes);+  @Accessor("BIOMES") 
 +  public static void setBiomes(List<RegistryKey<Biome>> biomes) { 
 +    throw new AssertionError();
   }   }
 } }
 </code> </code>
  
-We need to specify the climate to which the biome is added.+Secondly, we need to specify the climate to which the biome is added.
 In this tutorial, we will add the custom biome to the temperate climate as an example. In this tutorial, we will add the custom biome to the temperate climate as an example.
 We modify ''SetBaseBiomesLayer.TEMPERATE_BIOMES'' to accomplish this. We modify ''SetBaseBiomesLayer.TEMPERATE_BIOMES'' to accomplish this.
tutorial/biomes.txt · Last modified: 2022/08/16 20:50 by mineblock11