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 [2020/09/04 17:22] – 1.16.2 siglongtutorial: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 look the Minecraft Wikia for more information.]]**.//
-**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. +
- +
-==== Introduction ====+
  
 +====== Adding Biomes [1.16.3] ======
 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 7:
   * 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 22:
   // 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 59: Line 59:
       .downfall(0.4F)       .downfall(0.4F)
       .effects((new BiomeEffects.Builder())       .effects((new BiomeEffects.Builder())
-        .waterColor(4159204+        .waterColor(0x3f76e4
-        .waterFogColor(329011+        .waterFogColor(0x050533
-        .fogColor(12638463+        .fogColor(0xc0d8ff
-        .skyColor(7843327)+        .skyColor(0x77adff)
         .build())         .build())
       .spawnSettings(spawnSettings.build())       .spawnSettings(spawnSettings.build())
Line 82: Line 82:
   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 96:
  
 ==== 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''+We need to specify the climate to which the biome is addedthe biome which we are addingand the weight of the biome (a double value). 
-We have to add our biome to ''VanillaLayeredBiomeSource'' 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 spawnproportional to the weights of other biomes. 
-<code java> +You may want to give your biome a higher weight during testing so you can find the biome more easily
-@Mixin(VanillaLayeredBiomeSource.class) +In this tutorial, we will add the custom biome to the TEMPERATE and COOL climates as an example.
-public class VanillaLayeredBiomeSourceMixin { +
-  @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")) +
-  private static void addOverworldBiomes(Args args, long seed, boolean legacyBiomeInitLayer, boolean largeBiomes, +
-      Registry<Biome> biomeRegistry) { +
-    Stream<Supplier<Biome>> biomes = args.get(0); +
-    biomes = Stream.concat(biomes, Stream.of(() -> biomeRegistry.get(ExampleMod.OBSILAND_KEY))); +
-    args.set(0, biomes); +
-  } +
-+
-</code> +
- +
-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+
-We modify ''SetBaseBiomesLayer.TEMPERATE_BIOMES'' to accomplish this.+
  
 <code java> <code java>
Line 134: Line 108:
     [...]     [...]
  
-    // SetBaseBiomesLayer.TEMPERATE_BIOMES is an array of raw biome IDs+    OverworldBiomes.addContinentalBiome(OBSILAND_KEY, OverworldClimate.TEMPERATE, 2D); 
-    // We have to get the raw id of our biome and append it to TEMPERATE_BIOMES. +    OverworldBiomes.addContinentalBiome(OBSILAND_KEY, OverworldClimate.COOL2D);
-    SetBaseBiomesLayer.TEMPERATE_BIOMES = ArrayUtils.add(SetBaseBiomesLayer.TEMPERATE_BIOMESBuiltinRegistries.BIOME.getRawId(OBSILAND));+
   }   }
 } }
-</code> 
- 
-We have to use [[tutorial:accesswideners|Access Wideners]] to modify ''SetBaseBiomesLayer.TEMPERATE_BIOMES'' because it is a privte static field. 
-Your ''modid.accesswidener'' should look like: 
- 
-<code> 
-accessWidener v1 named 
- 
-accessible field net/minecraft/world/biome/layer/SetBaseBiomesLayer TEMPERATE_BIOMES [I 
-mutable    field net/minecraft/world/biome/layer/SetBaseBiomesLayer TEMPERATE_BIOMES [I 
 </code> </code>
  
Line 160: Line 123:
  
 {{tutorial:obsiland.png}} {{tutorial:obsiland.png}}
 +
tutorial/biomes.1599240160.txt.gz · Last modified: 2020/09/04 17:22 by siglong