[Change] Moved Nether Config Settings to BiomeSource-Config
This commit is contained in:
parent
d6cf5a6cd9
commit
85f1d7b1e4
6 changed files with 69 additions and 45 deletions
|
@ -93,7 +93,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
super(biomeRegistry, list, seed);
|
||||
this.config = config;
|
||||
var includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
|
||||
var excludeList = Configs.BIOMES_CONFIG.getBiomeExcludeMap().get(BiomeAPI.BiomeType.END);
|
||||
var excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END);
|
||||
|
||||
endLandBiomePicker = new BiomePicker(biomeRegistry);
|
||||
endVoidBiomePicker = new BiomePicker(biomeRegistry);
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
|||
import org.betterx.bclib.api.v2.generator.map.MapStack;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.config.ConfigKeeper.StringArrayEntry;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.bclib.util.TriFunction;
|
||||
|
@ -116,20 +115,16 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
}
|
||||
|
||||
private static List<Holder<Biome>> getBclBiomes(Registry<Biome> biomeRegistry) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getEntry("force_include", "nether_biomes", StringArrayEntry.class)
|
||||
.getValue();
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getEntry("force_exclude", "nether_biomes", StringArrayEntry.class)
|
||||
.getValue();
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
return getBiomes(biomeRegistry, exclude, include, BCLibNetherBiomeSource::isValidNonVanillaNetherBiome);
|
||||
}
|
||||
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getEntry("force_include", "nether_biomes", StringArrayEntry.class)
|
||||
.getValue();
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getEntry("force_exclude", "nether_biomes", StringArrayEntry.class)
|
||||
.getValue();
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
return getBiomes(biomeRegistry, exclude, include, BCLibNetherBiomeSource::isValidNetherBiome);
|
||||
}
|
||||
|
@ -177,19 +172,19 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
@Override
|
||||
protected void onInitMap(long seed) {
|
||||
TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor = config.mapVersion.mapBuilder;
|
||||
if (maxHeight > 128 && GeneratorOptions.useVerticalBiomes()) {
|
||||
if (maxHeight > config.biomeSizeVertical * 1.5 && config.useVerticalBiomes) {
|
||||
this.biomeMap = new MapStack(
|
||||
seed,
|
||||
GeneratorOptions.getBiomeSizeNether(),
|
||||
config.biomeSize,
|
||||
biomePicker,
|
||||
GeneratorOptions.getVerticalBiomeSizeNether(),
|
||||
config.biomeSizeVertical,
|
||||
maxHeight,
|
||||
mapConstructor
|
||||
);
|
||||
} else {
|
||||
this.biomeMap = mapConstructor.apply(
|
||||
seed,
|
||||
GeneratorOptions.getBiomeSizeNether(),
|
||||
config.biomeSize,
|
||||
biomePicker
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,43 +2,28 @@ package org.betterx.bclib.api.v2.generator;
|
|||
|
||||
import org.betterx.bclib.config.Configs;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class GeneratorOptions {
|
||||
private static int biomeSizeNether;
|
||||
private static int biomeVSizeNether;
|
||||
private static BiFunction<Point, Integer, Boolean> endLandFunction;
|
||||
private static boolean customNetherBiomeSource = true;
|
||||
private static boolean customEndBiomeSource = true;
|
||||
private static boolean verticalBiomes = true;
|
||||
private static long farEndBiomesSqr = 1000000;
|
||||
private static boolean fixEndBiomeSource = true;
|
||||
private static boolean fixNetherBiomeSource = true;
|
||||
|
||||
public static void init() {
|
||||
biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256);
|
||||
biomeVSizeNether = Configs.GENERATOR_CONFIG.getInt(
|
||||
"nether.biomeMap",
|
||||
"biomeVerticalSize(onlyInTallNether)",
|
||||
86
|
||||
);
|
||||
customNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customNetherBiomeSource", true);
|
||||
customEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customEndBiomeSource", true);
|
||||
verticalBiomes = Configs.GENERATOR_CONFIG.getBoolean("options", "verticalBiomesInTallNether", true);
|
||||
fixEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixEndBiomeSource", true);
|
||||
fixNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixNetherBiomeSource", true);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int getBiomeSizeNether() {
|
||||
return Mth.clamp(biomeSizeNether, 1, 8192);
|
||||
return 256;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int getVerticalBiomeSizeNether() {
|
||||
return Mth.clamp(biomeVSizeNether, 1, 8192);
|
||||
return 86;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
|
@ -68,8 +53,9 @@ public class GeneratorOptions {
|
|||
return endLandFunction;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static long getFarEndBiomes() {
|
||||
return farEndBiomesSqr;
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,8 +63,8 @@ public class GeneratorOptions {
|
|||
*
|
||||
* @param distance
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void setFarEndBiomes(int distance) {
|
||||
GeneratorOptions.farEndBiomesSqr = (long) distance * (long) distance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,21 +72,25 @@ public class GeneratorOptions {
|
|||
*
|
||||
* @param distanceSqr the distance squared
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void setFarEndBiomesSqr(long distanceSqr) {
|
||||
GeneratorOptions.farEndBiomesSqr = distanceSqr;
|
||||
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static boolean customNetherBiomeSource() {
|
||||
return customNetherBiomeSource;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static boolean customEndBiomeSource() {
|
||||
return customEndBiomeSource;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static boolean useVerticalBiomes() {
|
||||
return verticalBiomes;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean fixEndBiomeSource() {
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.betterx.worlds.together.biomesource.config.BiomeSourceConfig;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -17,13 +18,22 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
public class BCLNetherBiomeSourceConfig implements BiomeSourceConfig<BCLibNetherBiomeSource> {
|
||||
public static final BCLNetherBiomeSourceConfig VANILLA = new BCLNetherBiomeSourceConfig(
|
||||
NetherBiomeMapType.VANILLA
|
||||
NetherBiomeMapType.VANILLA,
|
||||
256,
|
||||
86,
|
||||
false
|
||||
);
|
||||
public static final BCLNetherBiomeSourceConfig MINECRAFT_17 = new BCLNetherBiomeSourceConfig(
|
||||
NetherBiomeMapType.SQUARE
|
||||
NetherBiomeMapType.SQUARE,
|
||||
256,
|
||||
86,
|
||||
true
|
||||
);
|
||||
public static final BCLNetherBiomeSourceConfig MINECRAFT_18 = new BCLNetherBiomeSourceConfig(
|
||||
NetherBiomeMapType.HEX
|
||||
NetherBiomeMapType.HEX,
|
||||
MINECRAFT_17.biomeSize,
|
||||
MINECRAFT_17.biomeSizeVertical,
|
||||
MINECRAFT_17.useVerticalBiomes
|
||||
);
|
||||
public static final BCLNetherBiomeSourceConfig DEFAULT = MINECRAFT_18;
|
||||
|
||||
|
@ -32,13 +42,32 @@ public class BCLNetherBiomeSourceConfig implements BiomeSourceConfig<BCLibNether
|
|||
BCLNetherBiomeSourceConfig.NetherBiomeMapType.CODEC
|
||||
.fieldOf("map_type")
|
||||
.orElse(DEFAULT.mapVersion)
|
||||
.forGetter(o -> o.mapVersion)
|
||||
.forGetter(o -> o.mapVersion),
|
||||
Codec.INT.fieldOf("biome_size").orElse(DEFAULT.biomeSize).forGetter(o -> o.biomeSize),
|
||||
Codec.INT.fieldOf("biome_size_vertical")
|
||||
.orElse(DEFAULT.biomeSizeVertical)
|
||||
.forGetter(o -> o.biomeSizeVertical),
|
||||
Codec.BOOL.fieldOf("use_vertical_biomes")
|
||||
.orElse(DEFAULT.useVerticalBiomes)
|
||||
.forGetter(o -> o.useVerticalBiomes)
|
||||
)
|
||||
.apply(instance, BCLNetherBiomeSourceConfig::new));
|
||||
public final @NotNull NetherBiomeMapType mapVersion;
|
||||
public final int biomeSize;
|
||||
public final int biomeSizeVertical;
|
||||
|
||||
public BCLNetherBiomeSourceConfig(@NotNull NetherBiomeMapType mapVersion) {
|
||||
public final boolean useVerticalBiomes;
|
||||
|
||||
public BCLNetherBiomeSourceConfig(
|
||||
@NotNull NetherBiomeMapType mapVersion,
|
||||
int biomeSize,
|
||||
int biomeSizeVertical,
|
||||
boolean useVerticalBiomes
|
||||
) {
|
||||
this.mapVersion = mapVersion;
|
||||
this.biomeSize = Mth.clamp(biomeSize, 1, 8192);
|
||||
this.biomeSizeVertical = Mth.clamp(biomeSizeVertical, 1, 8192);
|
||||
this.useVerticalBiomes = useVerticalBiomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -207,7 +207,10 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
BCLNetherBiomeSourceConfig netherConfig = new BCLNetherBiomeSourceConfig(
|
||||
netherLegacy.isChecked()
|
||||
? BCLNetherBiomeSourceConfig.NetherBiomeMapType.SQUARE
|
||||
: BCLNetherBiomeSourceConfig.NetherBiomeMapType.HEX
|
||||
: BCLNetherBiomeSourceConfig.NetherBiomeMapType.HEX,
|
||||
BCLNetherBiomeSourceConfig.DEFAULT.biomeSize,
|
||||
BCLNetherBiomeSourceConfig.DEFAULT.biomeSizeVertical,
|
||||
BCLNetherBiomeSourceConfig.DEFAULT.useVerticalBiomes
|
||||
);
|
||||
|
||||
ChunkGenerator netherGenerator = betterxDimensions.get(LevelStem.NETHER);
|
||||
|
|
|
@ -79,6 +79,13 @@ public class BiomesConfig extends PathConfig {
|
|||
.toList();
|
||||
}
|
||||
|
||||
public List<String> getExcludeMatching(BiomeAPI.BiomeType type) {
|
||||
var list = getBiomeExcludeMap().get(type);
|
||||
if (list == null) return List.of();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public Map<BiomeAPI.BiomeType, List<String>> getBiomeIncludeMap() {
|
||||
if (BIOME_INCLUDE_LIST == null) {
|
||||
BIOME_INCLUDE_LIST = new HashMap<>();
|
||||
|
|
Loading…
Reference in a new issue