Biome configuration fix
This commit is contained in:
parent
6c2c943b0d
commit
31f61f3f37
4 changed files with 47 additions and 14 deletions
|
@ -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.feature.ConfiguredStructureFeature;
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import ru.bclib.config.Configs;
|
||||||
import ru.bclib.util.MHelper;
|
import ru.bclib.util.MHelper;
|
||||||
import ru.bclib.world.biomes.BCLBiome;
|
import ru.bclib.world.biomes.BCLBiome;
|
||||||
import ru.bclib.world.biomes.FabricBiomesData;
|
import ru.bclib.world.biomes.FabricBiomesData;
|
||||||
|
@ -140,6 +141,7 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerNetherBiome(Biome biome) {
|
public static BCLBiome registerNetherBiome(Biome biome) {
|
||||||
BCLBiome bclBiome = new BCLBiome(biome);
|
BCLBiome bclBiome = new BCLBiome(biome);
|
||||||
|
configureBiome(bclBiome, 1.0F, 1.0F);
|
||||||
NETHER_BIOME_PICKER.addBiome(bclBiome);
|
NETHER_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
return bclBiome;
|
return bclBiome;
|
||||||
|
@ -153,6 +155,7 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndLandBiome(BCLBiome biome) {
|
public static BCLBiome registerEndLandBiome(BCLBiome biome) {
|
||||||
registerBiome(biome);
|
registerBiome(biome);
|
||||||
|
configureBiome(biome, 1.0F, 1.0F);
|
||||||
END_LAND_BIOME_PICKER.addBiome(biome);
|
END_LAND_BIOME_PICKER.addBiome(biome);
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||||
|
@ -169,6 +172,7 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndLandBiome(Biome biome) {
|
public static BCLBiome registerEndLandBiome(Biome biome) {
|
||||||
BCLBiome bclBiome = new BCLBiome(biome);
|
BCLBiome bclBiome = new BCLBiome(biome);
|
||||||
|
configureBiome(bclBiome, 1.0F, 1.0F);
|
||||||
END_LAND_BIOME_PICKER.addBiome(bclBiome);
|
END_LAND_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
return bclBiome;
|
return bclBiome;
|
||||||
|
@ -182,7 +186,8 @@ public class BiomeAPI {
|
||||||
* @return {@link BCLBiome}
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndLandBiome(Biome biome, float genChance) {
|
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);
|
END_LAND_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
return bclBiome;
|
return bclBiome;
|
||||||
|
@ -196,6 +201,7 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndVoidBiome(BCLBiome biome) {
|
public static BCLBiome registerEndVoidBiome(BCLBiome biome) {
|
||||||
registerBiome(biome);
|
registerBiome(biome);
|
||||||
|
configureBiome(biome, 1.0F, 1.0F);
|
||||||
END_VOID_BIOME_PICKER.addBiome(biome);
|
END_VOID_BIOME_PICKER.addBiome(biome);
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||||
|
@ -211,6 +217,7 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndVoidBiome(Biome biome) {
|
public static BCLBiome registerEndVoidBiome(Biome biome) {
|
||||||
BCLBiome bclBiome = new BCLBiome(biome);
|
BCLBiome bclBiome = new BCLBiome(biome);
|
||||||
|
configureBiome(bclBiome, 1.0F, 1.0F);
|
||||||
END_VOID_BIOME_PICKER.addBiome(bclBiome);
|
END_VOID_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
return bclBiome;
|
return bclBiome;
|
||||||
|
@ -225,7 +232,8 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndVoidBiome(Biome biome, float genChance) {
|
public static BCLBiome registerEndVoidBiome(Biome biome, float genChance) {
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
ResourceKey<Biome> 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);
|
END_VOID_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
return bclBiome;
|
return bclBiome;
|
||||||
|
@ -488,4 +496,11 @@ public class BiomeAPI {
|
||||||
maxGroupCount
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ public class Configs {
|
||||||
MAIN_CONFIG.saveChanges();
|
MAIN_CONFIG.saveChanges();
|
||||||
RECIPE_CONFIG.saveChanges();
|
RECIPE_CONFIG.saveChanges();
|
||||||
GENERATOR_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();
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,17 +53,31 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
||||||
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
|
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
|
||||||
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();
|
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();
|
||||||
|
|
||||||
|
List<String> includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue();
|
||||||
this.possibleBiomes().forEach(biome -> {
|
this.possibleBiomes().forEach(biome -> {
|
||||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||||
if (!BiomeAPI.hasBiome(key)) {
|
if (!BiomeAPI.hasBiome(key)) {
|
||||||
BCLBiome bclBiome = new BCLBiome(key, biome);
|
String group = key.getNamespace() + "." + key.getPath();
|
||||||
BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome);
|
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 {
|
else {
|
||||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||||
if (bclBiome != BiomeAPI.EMPTY_BIOME && bclBiome.getParentBiome() == null) {
|
if (bclBiome != BiomeAPI.EMPTY_BIOME && bclBiome.getParentBiome() == null) {
|
||||||
if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) && !BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key)) {
|
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<Biome> getBiomes(Registry<Biome> biomeRegistry) {
|
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
|
||||||
List<String> include = Configs.BIOMES_CONFIG.getEntry("force_include", "end_biomes", StringArrayEntry.class).getValue();
|
List<String> includeLand = Configs.BIOMES_CONFIG.getEntry("force_include", "end_land_biomes", StringArrayEntry.class).getValue();
|
||||||
|
List<String> includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue();
|
||||||
|
|
||||||
return biomeRegistry.stream().filter(biome -> {
|
return biomeRegistry.stream().filter(biome -> {
|
||||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||||
|
|
||||||
if (include.contains(key.toString())) {
|
if (includeLand.contains(key.toString()) || includeVoid.contains(key.toString())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,10 @@ public class BCLibNetherBiomeSource extends BiomeSource {
|
||||||
this.possibleBiomes().forEach(biome -> {
|
this.possibleBiomes().forEach(biome -> {
|
||||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||||
if (!BiomeAPI.hasBiome(key)) {
|
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);
|
BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue