diff --git a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java index 1ef912f2..ac80904a 100644 --- a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java @@ -27,6 +27,7 @@ import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import org.jetbrains.annotations.Nullable; +import ru.bclib.config.Configs; import ru.bclib.util.MHelper; import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.FabricBiomesData; @@ -140,6 +141,7 @@ public class BiomeAPI { */ public static BCLBiome registerNetherBiome(Biome biome) { BCLBiome bclBiome = new BCLBiome(biome); + configureBiome(bclBiome, 1.0F, 1.0F); NETHER_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -153,6 +155,7 @@ public class BiomeAPI { */ public static BCLBiome registerEndLandBiome(BCLBiome biome) { registerBiome(biome); + configureBiome(biome, 1.0F, 1.0F); END_LAND_BIOME_PICKER.addBiome(biome); float weight = biome.getGenChance(); ResourceKey key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get(); @@ -169,6 +172,7 @@ public class BiomeAPI { */ public static BCLBiome registerEndLandBiome(Biome biome) { BCLBiome bclBiome = new BCLBiome(biome); + configureBiome(bclBiome, 1.0F, 1.0F); END_LAND_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -182,7 +186,8 @@ public class BiomeAPI { * @return {@link BCLBiome} */ public static BCLBiome registerEndLandBiome(Biome biome, float genChance) { - BCLBiome bclBiome = new BCLBiome(biome).setGenChance(genChance); + BCLBiome bclBiome = new BCLBiome(biome); + configureBiome(bclBiome, genChance, 1.0F); END_LAND_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -196,6 +201,7 @@ public class BiomeAPI { */ public static BCLBiome registerEndVoidBiome(BCLBiome biome) { registerBiome(biome); + configureBiome(biome, 1.0F, 1.0F); END_VOID_BIOME_PICKER.addBiome(biome); float weight = biome.getGenChance(); ResourceKey key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get(); @@ -211,6 +217,7 @@ public class BiomeAPI { */ public static BCLBiome registerEndVoidBiome(Biome biome) { BCLBiome bclBiome = new BCLBiome(biome); + configureBiome(bclBiome, 1.0F, 1.0F); END_VOID_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -225,7 +232,8 @@ public class BiomeAPI { */ public static BCLBiome registerEndVoidBiome(Biome biome, float genChance) { ResourceKey key = BuiltinRegistries.BIOME.getResourceKey(biome).get(); - BCLBiome bclBiome = new BCLBiome(biome).setGenChance(genChance); + BCLBiome bclBiome = new BCLBiome(biome); + configureBiome(bclBiome, genChance, 1.0F); END_VOID_BIOME_PICKER.addBiome(bclBiome); registerBiome(bclBiome); return bclBiome; @@ -488,4 +496,11 @@ public class BiomeAPI { maxGroupCount ); } + + private static void configureBiome(BCLBiome biome, float chance, float fog) { + String group = biome.getID().getNamespace() + "." + biome.getID().getPath(); + chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", chance); + fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", fog); + biome.setGenChance(chance).setFogDensity(fog); + } } diff --git a/src/main/java/ru/bclib/config/Configs.java b/src/main/java/ru/bclib/config/Configs.java index deac17d2..1e82f759 100644 --- a/src/main/java/ru/bclib/config/Configs.java +++ b/src/main/java/ru/bclib/config/Configs.java @@ -26,12 +26,12 @@ public class Configs { MAIN_CONFIG.saveChanges(); RECIPE_CONFIG.saveChanges(); GENERATOR_CONFIG.saveChanges(); - initForcedConfig(); - } - - private static void initForcedConfig() { - BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("end_biomes", "force_include"), new StringArrayEntry(Collections.EMPTY_LIST)); - BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("nether_biomes", "force_include"), new StringArrayEntry(Collections.EMPTY_LIST)); BIOMES_CONFIG.saveChanges(); } + + static { + BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("end_land_biomes", "force_include"), new StringArrayEntry(Collections.EMPTY_LIST)); + BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("end_void_biomes", "force_include"), new StringArrayEntry(Collections.EMPTY_LIST)); + BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("nether_biomes", "force_include"), new StringArrayEntry(Collections.EMPTY_LIST)); + } } diff --git a/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java index 1fb41e50..9392481f 100644 --- a/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java @@ -53,17 +53,31 @@ public class BCLibEndBiomeSource extends BiomeSource { BiomeAPI.END_LAND_BIOME_PICKER.clearMutables(); BiomeAPI.END_VOID_BIOME_PICKER.clearMutables(); + List includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue(); this.possibleBiomes().forEach(biome -> { ResourceLocation key = biomeRegistry.getKey(biome); if (!BiomeAPI.hasBiome(key)) { - BCLBiome bclBiome = new BCLBiome(key, biome); - BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome); + String group = key.getNamespace() + "." + key.getPath(); + float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", 1.0F); + float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", 1.0F); + BCLBiome bclBiome = new BCLBiome(key, biome).setGenChance(chance).setFogDensity(fog); + if (includeVoid.contains(key.toString())) { + BiomeAPI.END_VOID_BIOME_PICKER.addBiomeMutable(bclBiome); + } + else { + BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome); + } } else { BCLBiome bclBiome = BiomeAPI.getBiome(key); if (bclBiome != BiomeAPI.EMPTY_BIOME && bclBiome.getParentBiome() == null) { if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) && !BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key)) { - BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome); + if (includeVoid.contains(key.toString())) { + BiomeAPI.END_VOID_BIOME_PICKER.addBiomeMutable(bclBiome); + } + else { + BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome); + } } } } @@ -100,12 +114,13 @@ public class BCLibEndBiomeSource extends BiomeSource { } private static List getBiomes(Registry biomeRegistry) { - List include = Configs.BIOMES_CONFIG.getEntry("force_include", "end_biomes", StringArrayEntry.class).getValue(); + List includeLand = Configs.BIOMES_CONFIG.getEntry("force_include", "end_land_biomes", StringArrayEntry.class).getValue(); + List includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue(); return biomeRegistry.stream().filter(biome -> { ResourceLocation key = biomeRegistry.getKey(biome); - if (include.contains(key.toString())) { + if (includeLand.contains(key.toString()) || includeVoid.contains(key.toString())) { return true; } diff --git a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java index ad1f157a..9e524341 100644 --- a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java @@ -45,7 +45,10 @@ public class BCLibNetherBiomeSource extends BiomeSource { this.possibleBiomes().forEach(biome -> { ResourceLocation key = biomeRegistry.getKey(biome); if (!BiomeAPI.hasBiome(key)) { - BCLBiome bclBiome = new BCLBiome(key, biome); + String group = key.getNamespace() + "." + key.getPath(); + float chance = Configs.BIOMES_CONFIG.getFloat(group, "generation_chance", 1.0F); + float fog = Configs.BIOMES_CONFIG.getFloat(group, "fog_density", 1.0F); + BCLBiome bclBiome = new BCLBiome(key, biome).setGenChance(chance).setFogDensity(fog); BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome); } else {