From b0f6dd6bff666eb2daa932fbd535b42b8cadbbb2 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 17 Jan 2022 14:06:22 +0100 Subject: [PATCH] Refactored Biome Config handling (#63) --- .../ru/bclib/api/biomes/BCLBiomeBuilder.java | 86 ++++++- .../java/ru/bclib/api/biomes/BiomeAPI.java | 35 ++- src/main/java/ru/bclib/util/TriFunction.java | 6 + .../java/ru/bclib/world/biomes/BCLBiome.java | 216 +++++++----------- .../bclib/world/biomes/BCLBiomeSettings.java | 185 +++++++++++++++ .../world/biomes/VanillaBiomeSettings.java | 14 ++ .../bclib/world/generator/BCLBiomeSource.java | 11 +- .../world/generator/BCLibEndBiomeSource.java | 4 +- .../generator/BCLibNetherBiomeSource.java | 4 +- 9 files changed, 389 insertions(+), 172 deletions(-) create mode 100644 src/main/java/ru/bclib/util/TriFunction.java create mode 100644 src/main/java/ru/bclib/world/biomes/BCLBiomeSettings.java create mode 100644 src/main/java/ru/bclib/world/biomes/VanillaBiomeSettings.java diff --git a/src/main/java/ru/bclib/api/biomes/BCLBiomeBuilder.java b/src/main/java/ru/bclib/api/biomes/BCLBiomeBuilder.java index 3dc52912..40df4eef 100644 --- a/src/main/java/ru/bclib/api/biomes/BCLBiomeBuilder.java +++ b/src/main/java/ru/bclib/api/biomes/BCLBiomeBuilder.java @@ -34,7 +34,10 @@ import ru.bclib.api.surface.SurfaceRuleBuilder; import ru.bclib.entity.BCLEntityWrapper; import ru.bclib.mixin.common.BiomeGenerationSettingsAccessor; import ru.bclib.util.ColorUtil; +import ru.bclib.util.TriFunction; import ru.bclib.world.biomes.BCLBiome; +import ru.bclib.world.biomes.BCLBiomeSettings; +import ru.bclib.world.biomes.BCLBiomeSettings.Builder; import ru.bclib.world.features.BCLFeature; import ru.bclib.world.structures.BCLStructureFeature; @@ -48,6 +51,10 @@ import java.util.function.Supplier; import java.util.stream.Collectors; public class BCLBiomeBuilder { + @FunctionalInterface + public interface BiomeSupplier extends TriFunction{ + } + private static final BCLBiomeBuilder INSTANCE = new BCLBiomeBuilder(); private static final SurfaceRules.ConditionSource SURFACE_NOISE = SurfaceRules.noiseCondition(Noises.SOUL_SAND_LAYER, -0.012); @@ -64,6 +71,10 @@ public class BCLBiomeBuilder { private float genChance; private float downfall; private float height; + private int edgeSize; + private BCLBiome edge; + private boolean vertical; + /** * Starts new biome building process. @@ -80,9 +91,12 @@ public class BCLBiomeBuilder { INSTANCE.structures.clear(); INSTANCE.temperature = 1.0F; INSTANCE.fogDensity = 1.0F; + INSTANCE.edgeSize = 0; INSTANCE.downfall = 1.0F; INSTANCE.genChance = 1.0F; INSTANCE.height = 0.1F; + INSTANCE.vertical = false; + INSTANCE.edge = null; return INSTANCE; } @@ -234,6 +248,40 @@ public class BCLBiomeBuilder { return this; } + /** + * Sets edge size for this biome. + * @param edgeSize size of the Edge (in Blocks) + * @return same {@link BCLBiomeBuilder}. + */ + public BCLBiomeBuilder edgeSize(int edgeSize) { + this.edgeSize = edgeSize; + return this; + } + + /** + * Sets edge-Biome for this biome. + * @param edge The Edge Biome + * @return same {@link BCLBiomeBuilder}. + */ + public BCLBiomeBuilder edge(BCLBiome edge) { + this.edge = edge; + return this; + } + + + + /** + * Sets edge-Biome for this biome. + * @param edge The Edge Biome + * @param edgeSize size of the Edge (in Blocks) + * @return same {@link BCLBiomeBuilder}. + */ + public BCLBiomeBuilder edge(BCLBiome edge, int edgeSize) { + this.edge(edge); + this.edgeSize(edgeSize); + return this; + } + /** * Sets water color for the biome. Color is in ARGB int format. * @param color ARGB color as integer. @@ -579,12 +627,24 @@ public class BCLBiomeBuilder { return this; } + + + /** + * Make this a vertical Biome + * + * @return same {@link BCLBiomeBuilder} instance. + */ + public BCLBiomeBuilder vertical() { + this.vertical = vertical; + return this; + } + /** * Finalize biome creation. * @return created {@link BCLBiome} instance. */ public BCLBiome build() { - return build(BCLBiome::new); + return build((BiomeSupplier)BCLBiome::new); } /** @@ -592,7 +652,17 @@ public class BCLBiomeBuilder { * @param biomeConstructor {@link BiFunction} biome constructor. * @return created {@link BCLBiome} instance. */ + @Deprecated(forRemoval = true) public T build(BiFunction biomeConstructor) { + return build((id, biome, settings)->biomeConstructor.apply(id, biome)); + } + + /** + * Finalize biome creation. + * @param biomeConstructor {@link BiomeSupplier} biome constructor. + * @return created {@link BCLBiome} instance. + */ + public T build(BiomeSupplier biomeConstructor) { BiomeBuilder builder = new BiomeBuilder() .precipitation(precipitation) .biomeCategory(category) @@ -622,12 +692,18 @@ public class BCLBiomeBuilder { builder.generationSettings(getGeneration().build()); } - final T res = biomeConstructor.apply(biomeID, builder.build()); - res.setTerrainHeight(height); + BCLBiomeSettings settings = BCLBiomeSettings.createBCL() + .setTerrainHeight(height) + .setFogDensity(fogDensity) + .setGenChance(genChance) + .setEdgeSize(edgeSize) + .setEdge(edge) + .setVertical(vertical) + .build(); + + final T res = biomeConstructor.apply(biomeID, builder.build(), settings); res.attachStructures(structures); res.setSurface(surfaceRule); - res.setFogDensity(fogDensity); - res.setGenChance(genChance); res.setFeatures(defferedFeatures); return res; } diff --git a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java index d56469a4..43bfe1a1 100644 --- a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java @@ -69,7 +69,9 @@ import ru.bclib.mixin.common.StructureSettingsAccessor; import ru.bclib.util.CollectionsUtil; import ru.bclib.util.MHelper; import ru.bclib.world.biomes.BCLBiome; +import ru.bclib.world.biomes.BCLBiomeSettings; import ru.bclib.world.biomes.FabricBiomesData; +import ru.bclib.world.biomes.VanillaBiomeSettings; import ru.bclib.world.features.BCLFeature; import ru.bclib.world.generator.BiomePicker; import ru.bclib.world.structures.BCLStructureFeature; @@ -216,7 +218,7 @@ public class BiomeAPI { } public static BCLBiome registerSubBiome(BCLBiome parent, Biome biome, float genChance) { - BCLBiome subBiome = new BCLBiome(biome).setGenChance(genChance); + BCLBiome subBiome = new BCLBiome(biome, VanillaBiomeSettings.createVanilla().setGenChance(genChance).build()); return registerSubBiome(parent, subBiome); } @@ -253,8 +255,8 @@ public class BiomeAPI { * @return {@link BCLBiome} */ public static BCLBiome registerNetherBiome(Biome biome) { - BCLBiome bclBiome = new BCLBiome(biome); - configureBiome(bclBiome); + BCLBiome bclBiome = new BCLBiome(biome, null); + NETHER_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -268,7 +270,7 @@ public class BiomeAPI { */ public static BCLBiome registerEndLandBiome(BCLBiome biome) { registerBiome(biome); - configureBiome(biome); + END_LAND_BIOME_PICKER.addBiome(biome); float weight = biome.getGenChance(); ResourceKey key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).orElseThrow(); @@ -284,8 +286,8 @@ public class BiomeAPI { * @return {@link BCLBiome} */ public static BCLBiome registerEndLandBiome(Biome biome) { - BCLBiome bclBiome = new BCLBiome(biome); - configureBiome(bclBiome); + BCLBiome bclBiome = new BCLBiome(biome, null); + END_LAND_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -299,8 +301,8 @@ public class BiomeAPI { * @return {@link BCLBiome} */ public static BCLBiome registerEndLandBiome(Biome biome, float genChance) { - BCLBiome bclBiome = new BCLBiome(biome).setGenChance(genChance); - configureBiome(bclBiome); + BCLBiome bclBiome = new BCLBiome(biome, VanillaBiomeSettings.createVanilla().setGenChance(genChance).build()); + END_LAND_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -314,7 +316,7 @@ public class BiomeAPI { */ public static BCLBiome registerEndVoidBiome(BCLBiome biome) { registerBiome(biome); - configureBiome(biome); + END_VOID_BIOME_PICKER.addBiome(biome); float weight = biome.getGenChance(); ResourceKey key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).orElseThrow(); @@ -329,8 +331,8 @@ public class BiomeAPI { * @return {@link BCLBiome} */ public static BCLBiome registerEndVoidBiome(Biome biome) { - BCLBiome bclBiome = new BCLBiome(biome); - configureBiome(bclBiome); + BCLBiome bclBiome = new BCLBiome(biome, null); + END_VOID_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -344,8 +346,8 @@ public class BiomeAPI { * @return {@link BCLBiome} */ public static BCLBiome registerEndVoidBiome(Biome biome, float genChance) { - BCLBiome bclBiome = new BCLBiome(biome).setGenChance(genChance); - configureBiome(bclBiome); + BCLBiome bclBiome = new BCLBiome(biome, VanillaBiomeSettings.createVanilla().setGenChance(genChance).build()); + END_VOID_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -993,13 +995,6 @@ public class BiomeAPI { }); } - private static void configureBiome(BCLBiome biome) { - String group = biome.getID().getNamespace() + "." + biome.getID().getPath(); - float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", biome.getGenChance()); - float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", biome.getFogDensity()); - biome.setGenChance(chance).setFogDensity(fog); - } - /** * Getter for correct feature list from all biome feature list of lists. * @param step feature {@link Decoration} step. diff --git a/src/main/java/ru/bclib/util/TriFunction.java b/src/main/java/ru/bclib/util/TriFunction.java new file mode 100644 index 00000000..d58760d3 --- /dev/null +++ b/src/main/java/ru/bclib/util/TriFunction.java @@ -0,0 +1,6 @@ +package ru.bclib.util; + +@FunctionalInterface +public interface TriFunction { + R apply(A a, B b, C c); +} diff --git a/src/main/java/ru/bclib/world/biomes/BCLBiome.java b/src/main/java/ru/bclib/world/biomes/BCLBiome.java index 01744f78..0c115656 100644 --- a/src/main/java/ru/bclib/world/biomes/BCLBiome.java +++ b/src/main/java/ru/bclib/world/biomes/BCLBiome.java @@ -25,7 +25,7 @@ import java.util.Random; import java.util.function.Consumer; import java.util.function.Supplier; -public class BCLBiome { +public class BCLBiome extends BCLBiomeSettings { private final List structures = Lists.newArrayList(); private final WeightedList subbiomes = new WeightedList<>(); private final Map customData = Maps.newHashMap(); @@ -35,13 +35,6 @@ public class BCLBiome { private Consumer surfaceInit; private BCLBiome biomeParent; private Biome actualBiome; - private BCLBiome edge; - - private float terrainHeight = 0.1F; - private float fogDensity = 1.0F; - private float genChance = 1.0F; - private int edgeSize = 0; - private boolean vertical; /** * Create wrapper for existing biome using its {@link ResourceLocation} identifier. @@ -56,7 +49,7 @@ public class BCLBiome { * @param biomeID {@link ResourceLocation} biome ID. */ public BCLBiome(ResourceLocation biomeID) { - this(biomeID, BuiltinRegistries.BIOME.get(biomeID)); + this(biomeID, BuiltinRegistries.BIOME.get(biomeID), null); } /** @@ -64,13 +57,36 @@ public class BCLBiome { * @param biome {@link Biome} to wrap. */ public BCLBiome(Biome biome) { - this(BuiltinRegistries.BIOME.getKey(biome), biome); + this(biome, null); + } + + /** + * Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}. + * @param biome {@link Biome} to wrap. + * @param settings The Settings for this Biome or {@code null} if you want to apply default settings + */ + public BCLBiome(Biome biome, VanillaBiomeSettings settings) { + this(BuiltinRegistries.BIOME.getKey(biome), biome, settings); } public BCLBiome(ResourceLocation biomeID, Biome biome) { + this(biomeID, biome, null); + } + + /** + * Create a new Biome + * @param biomeID {@link ResourceLocation} biome ID. + * @param biome {@link Biome} to wrap. + * @param defaults The Settings for this Biome or null if you want to apply the defaults + */ + public BCLBiome(ResourceLocation biomeID, Biome biome, BCLBiomeSettings defaults) { this.subbiomes.add(this, 1.0F); this.biomeID = biomeID; this.biome = biome; + + if (defaults !=null){ + defaults.applyWithDefaults(this); + } } /** @@ -87,30 +103,12 @@ public class BCLBiome { * @param edge {@link BCLBiome} as the edge biome. * @return same {@link BCLBiome}. */ - public BCLBiome setEdge(BCLBiome edge) { + BCLBiome setEdge(BCLBiome edge) { this.edge = edge; edge.biomeParent = this; return this; } - /** - * Getter for biome edge size. - * @return edge size in blocks. - */ - public int getEdgeSize() { - return edgeSize; - } - - /** - * Set edges size for this biome. Size is in blocks. - * @param size as a float value. - * @return same {@link BCLBiome}. - */ - public BCLBiome setEdgeSize(int size) { - edgeSize = size; - return this; - } - /** * Adds sub-biome into this biome instance. Biome chance will be interpreted as a sub-biome generation chance. * Biome itself has chance 1.0 compared to all its sub-biomes. @@ -167,23 +165,6 @@ public class BCLBiome { return biomeID; } - /** - * Getter for fog density, used in custom for renderer. - * @return fog density as a float. - */ - public float getFogDensity() { - return fogDensity; - } - - /** - * Sets fog density for this biome. - * @param fogDensity - * @return same {@link BCLBiome}. - */ - public BCLBiome setFogDensity(float fogDensity) { - this.fogDensity = fogDensity; - return this; - } /** * Getter for biome from buil-in registry. For datapack biomes will be same as actual biome. @@ -201,23 +182,7 @@ public class BCLBiome { return this.actualBiome; } - /** - * Getter for biome generation chance, used in {@link ru.bclib.world.generator.BiomePicker} and in custom generators. - * @return biome generation chance as float. - */ - public float getGenChance() { - return this.genChance; - } - /** - * Set gen chance for this biome, default value is 1.0. - * @param genChance chance of this biome to be generated. - * @return same {@link BCLBiome}. - */ - public BCLBiome setGenChance(float genChance) { - this.genChance = genChance; - return this; - } /** * Recursively update biomes to correct world biome registry instances, for internal usage only. @@ -289,50 +254,6 @@ public class BCLBiome { return this; } - /** - * Setter for terrain height, can be used in custom terrain generator. - * @param terrainHeight a relative float terrain height value. - * @return same {@link BCLBiome}. - */ - public BCLBiome setTerrainHeight(float terrainHeight) { - this.terrainHeight = terrainHeight; - return this; - } - - /** - * Getter for terrain height, can be used in custom terrain generator. - * @return terrain height. - */ - public float getTerrainHeight() { - return terrainHeight; - } - - /** - * Set biome vertical distribution (for tall Nether only). - * @return same {@link BCLBiome}. - */ - public BCLBiome setVertical() { - return setVertical(true); - } - - /** - * Set biome vertical distribution (for tall Nether only). - * @param vertical {@code boolean} value. - * @return same {@link BCLBiome}. - */ - public BCLBiome setVertical(boolean vertical) { - this.vertical = vertical; - return this; - } - - /** - * Checks if biome is vertical, for tall Nether only (or for custom generators). - * @return is biome vertical or not. - */ - public boolean isVertical() { - return vertical; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -406,29 +327,62 @@ public class BCLBiome { } private boolean didLoadConfig = false; - /** - * For internal use. - * Set Biome configuartion from Config. This method is called for all Biomes that get registered - * to a {@link ru.bclib.world.generator.BCLBiomeSource}. - * - * @return This instance - */ - public BCLBiome setupFromConfig() { - if (didLoadConfig) return this; - didLoadConfig = true; - - String group = this.configGroup(); - float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", this.getGenChance()); - float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", this.getFogDensity()); - this.setGenChance(chance).setFogDensity(fog); - - if (this.getEdge()!=null){ - int edgeSize = Configs.BIOMES_CONFIG.getInt(group, "edge_size", this.getEdgeSize()); - this.setEdgeSize(edgeSize); - } - - Configs.BIOMES_CONFIG.saveChanges(); - - return this; - } + +// /** +// * Set gen chance for this biome, default value is 1.0. +// * @param genChance chance of this biome to be generated. +// * @return same {@link BCLBiome}. +// */ +// public BCLBiome setGenChance(float genChance) { +// super.setGenChance(genChance); +// return this; +// } +// +// /** +// * Setter for terrain height, can be used in custom terrain generator. +// * @param terrainHeight a relative float terrain height value. +// * @return same {@link BCLBiome}. +// */ +// public BCLBiome setTerrainHeight(float terrainHeight) { +// super.setTerrainHeight(genChance); +// return this; +// } +// +// /** +// * Set biome vertical distribution (for tall Nether only). +// * @return same {@link BCLBiome}. +// */ +// public BCLBiome setVertical() { +// return setVertical(true); +// } +// +// /** +// * Set biome vertical distribution (for tall Nether only). +// * @param vertical {@code boolean} value. +// * @return same {@link BCLBiome}. +// */ +// public BCLBiome setVertical(boolean vertical) { +// super.setVertical(vertical); +// return this; +// } +// +// /** +// * Sets fog density for this biome. +// * @param fogDensity +// * @return same {@link BCLBiome}. +// */ +// public BCLBiome setFogDensity(float fogDensity) { +// super.setFogDensity(fogDensity); +// return this; +// } +// +// /** +// * Set edges size for this biome. Size is in blocks. +// * @param size as a float value. +// * @return same {@link BCLBiome}. +// */ +// public BCLBiome setEdgeSize(int size) { +// edgeSize = size; +// return this; +// } } diff --git a/src/main/java/ru/bclib/world/biomes/BCLBiomeSettings.java b/src/main/java/ru/bclib/world/biomes/BCLBiomeSettings.java new file mode 100644 index 00000000..f2efdecc --- /dev/null +++ b/src/main/java/ru/bclib/world/biomes/BCLBiomeSettings.java @@ -0,0 +1,185 @@ +package ru.bclib.world.biomes; + +import net.minecraft.world.level.biome.Biome; +import ru.bclib.config.Configs; +import ru.bclib.world.biomes.VanillaBiomeSettings.Builder; + +public class BCLBiomeSettings { + public static Builder createBCL(){ + return new Builder(); + } + + public static class Builder extends CommonBuilder{ + public Builder(){ + super(new BCLBiomeSettings()); + } + } + public static class CommonBuilder{ + private final T storage; + CommonBuilder(T storage){ + this.storage = storage; + } + + public T build(){ + return storage; + } + + /** + * Set gen chance for this biome, default value is 1.0. + * @param genChance chance of this biome to be generated. + * @return same {@link BCLBiomeSettings}. + */ + public R setGenChance(float genChance) { + storage.genChance = genChance; + return (R)this; + } + + /** + * Setter for terrain height, can be used in custom terrain generator. + * @param terrainHeight a relative float terrain height value. + * @return same {@link Builder}. + */ + public R setTerrainHeight(float terrainHeight) { + storage.terrainHeight = terrainHeight; + return (R)this; + } + + /** + * Set biome vertical distribution (for tall Nether only). + * @return same {@link Builder}. + */ + public R setVertical() { + return setVertical(true); + } + + /** + * Set biome vertical distribution (for tall Nether only). + * @param vertical {@code boolean} value. + * @return same {@link Builder}. + */ + public R setVertical(boolean vertical) { + storage.vertical = vertical; + return (R)this; + } + + /** + * Set edges size for this biome. Size is in blocks. + * @param size as a float value. + * @return same {@link Builder}. + */ + public R setEdgeSize(int size) { + storage.edgeSize = size; + return (R)this; + } + + /** + * Set edges:biome for this biome. + * @param edge The {@link Biome}. + * @return same {@link Builder}. + */ + public R setEdge(BCLBiome edge) { + storage.edge = edge; + return (R)this; + } + + /** + * Sets fog density for this biome. + * @param fogDensity + * @return same {@link Builder}. + */ + public R setFogDensity(float fogDensity) { + storage.fogDensity = fogDensity; + return (R)this; + } + } + + protected BCLBiomeSettings(){ + this.terrainHeight = 0.1F; + this.fogDensity = 1.0F; + this.genChance = 1.0F; + this.edgeSize = 0; + this.vertical = false; + this.edge = null; + } + + float terrainHeight; + float fogDensity; + float genChance; + int edgeSize; + boolean vertical; + BCLBiome edge; + + + /** + * Getter for biome generation chance, used in {@link ru.bclib.world.generator.BiomePicker} and in custom generators. + * @return biome generation chance as float. + */ + public float getGenChance() { + return this.genChance; + } + + /** + * Checks if biome is vertical, for tall Nether only (or for custom generators). + * @return is biome vertical or not. + */ + public boolean isVertical() { + return vertical; + } + + /** + * Getter for terrain height, can be used in custom terrain generator. + * @return terrain height. + */ + public float getTerrainHeight() { + return terrainHeight; + } + + /** + * Getter for fog density, used in custom for renderer. + * @return fog density as a float. + */ + public float getFogDensity() { + return fogDensity; + } + + /** + * Getter for biome edge size. + * @return edge size in blocks. + */ + public int getEdgeSize() { + return edgeSize; + } + + /** + * Getter for edge-biome. + * @return The assigned edge biome. + */ + public BCLBiome getEdge() { + return edge; + } + + /** + * Load values from Config and apply to the passed Biome. The Default values for the loaded settings + * are derifed from the values store in this object + * @param biome {@link BCLBiome} to assign values to + */ + public void applyWithDefaults(BCLBiome biome){ + final String group = biome.configGroup(); + biome.genChance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", this.genChance); + + if (edge!=null){ + biome.edgeSize = Configs.BIOMES_CONFIG.getInt(group, "edge_size", this.edgeSize); + if (edgeSize>0) { + biome.setEdge(edge); + } + } + + if (!(this instanceof VanillaBiomeSettings)){ + biome.fogDensity = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", this.fogDensity); + biome.vertical = Configs.BIOMES_CONFIG.getBoolean(group, "vertical", this.vertical); + biome.terrainHeight = Configs.BIOMES_CONFIG.getFloat(group, "terrain_height", this.terrainHeight); + } + + Configs.BIOMES_CONFIG.saveChanges(); + } +} diff --git a/src/main/java/ru/bclib/world/biomes/VanillaBiomeSettings.java b/src/main/java/ru/bclib/world/biomes/VanillaBiomeSettings.java new file mode 100644 index 00000000..1599bd11 --- /dev/null +++ b/src/main/java/ru/bclib/world/biomes/VanillaBiomeSettings.java @@ -0,0 +1,14 @@ +package ru.bclib.world.biomes; + + +public class VanillaBiomeSettings extends BCLBiomeSettings{ + public static class Builder extends BCLBiomeSettings.CommonBuilder{ + public Builder(){ + super(new VanillaBiomeSettings()); + } + } + + public static Builder createVanilla(){ + return new Builder(); + } +} diff --git a/src/main/java/ru/bclib/world/generator/BCLBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLBiomeSource.java index 3c73ff95..9ecaa92b 100644 --- a/src/main/java/ru/bclib/world/generator/BCLBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLBiomeSource.java @@ -5,6 +5,7 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeSource; import ru.bclib.api.biomes.BiomeAPI; import ru.bclib.world.biomes.BCLBiome; +import ru.bclib.world.biomes.BCLBiomeSettings; import java.util.List; @@ -25,14 +26,4 @@ public abstract class BCLBiomeSource extends BiomeSource { BiomeAPI.initRegistry(biomeRegistry); } - - /** - * Set Biome configuartion from Config - * @param bclBiome The biome you want to configure - * @return The input biome - */ - public static BCLBiome setupFromConfig(BCLBiome bclBiome) { - bclBiome.setupFromConfig(); - return bclBiome; - } } diff --git a/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java index d31aee30..a95763df 100644 --- a/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java @@ -58,7 +58,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource { String group = key.getNamespace() + "." + key.getPath(); if (!BiomeAPI.hasBiome(key)) { - BCLBiome bclBiome = setupFromConfig(new BCLBiome(key, biome)); + BCLBiome bclBiome = new BCLBiome(key, biome); if (includeVoid.contains(key.toString())) { BiomeAPI.END_VOID_BIOME_PICKER.addBiomeMutable(bclBiome); @@ -70,8 +70,6 @@ public class BCLibEndBiomeSource extends BCLBiomeSource { else { BCLBiome bclBiome = BiomeAPI.getBiome(key); if (bclBiome != BiomeAPI.EMPTY_BIOME) { - setupFromConfig(bclBiome); - if (bclBiome.getParentBiome() == null) { if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) && !BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key)) { if (includeVoid.contains(key.toString())) { diff --git a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java index 48754d37..78bb50e3 100644 --- a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java @@ -64,14 +64,12 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource { ResourceLocation key = biomeRegistry.getKey(biome); if (!BiomeAPI.hasBiome(key)) { - BCLBiome bclBiome = setupFromConfig(new BCLBiome(key, biome)); + BCLBiome bclBiome = new BCLBiome(key, biome); BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome); } else { BCLBiome bclBiome = BiomeAPI.getBiome(key); if (bclBiome != BiomeAPI.EMPTY_BIOME) { - setupFromConfig(bclBiome); - if (bclBiome.getParentBiome() == null) { if (!BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key)) { BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome);