tutorial:biomes
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:biome [2020/09/04 20:39] – Improve compatibility siglong | tutorial:biomes [2020/11/02 15:29] – Use Biome API in Fabric API siglong | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Adding | + | ====== Adding |
- | **NOTE:** There is [[https:// | + | |
- | Read 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 11: | Line 6: | ||
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 obsidians. | ||
+ | |||
+ | Note that this tutorial depends on [[https:// | ||
+ | If the API doesn' | ||
==== 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< | private static final ConfiguredSurfaceBuilder< | ||
- | .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, | Registry.register(BuiltinRegistries.CONFIGURED_SURFACE_BUILDER, | ||
- | |||
Registry.register(BuiltinRegistries.BIOME, | Registry.register(BuiltinRegistries.BIOME, | ||
- | BuiltinBiomesAccessor.getRawIdMap().put(BuiltinRegistries.BIOME.getRawId(OBSILAND), | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | <code java> | ||
- | @Mixin(BuiltinBiomes.class) | ||
- | public interface BuiltinBiomesAccessor { | ||
- | @Accessor(" | ||
- | public static Int2ObjectMap< | ||
- | 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 | + | We need to specify |
- | 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 | ||
+ | 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 | ||
<code java> | <code java> | ||
Line 117: | Line 106: | ||
[...] | [...] | ||
- | | + | |
- | List< | + | |
- | | + | |
- | VanillaLayeredBiomeSourceAccessor.setBiomes(biomes); | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | <code java> | + | |
- | @Mixin(VanillaLayeredBiomeSource.class) | + | |
- | public interface VanillaLayeredBiomeSourceAccessor { | + | |
- | @Accessor(" | + | |
- | public static List< | + | |
- | throw new AssertionError(); | + | |
- | } | + | |
- | + | ||
- | @Accessor(" | + | |
- | public static void setBiomes(List< | + | |
- | throw new AssertionError(); | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | 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. | + | |
- | We modify '' | + | |
- | + | ||
- | <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(), | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | <code java> | + | |
- | @Mixin(SetBaseBiomesLayer.class) | + | |
- | public interface SetBaseBiomesLayerAccessor { | + | |
- | @Accessor(" | + | |
- | public static int[] getTemperateBiomes() { | + | |
- | throw new AssertionError(); | + | |
- | } | + | |
- | + | ||
- | @Accessor(" | + | |
- | public static void setTemperateBiomes(int[] biomes) { | + | |
- | throw new AssertionError(); | + | |
} | } | ||
} | } | ||
Line 182: | Line 121: | ||
{{tutorial: | {{tutorial: | ||
+ |
tutorial/biomes.txt · Last modified: 2022/08/16 20:50 by mineblock11