override for the nether biome generator that is used by BN when older worlds are loaded

This commit is contained in:
Frank 2021-12-03 00:31:53 +01:00
parent 39255e140f
commit c6dc52a60d
2 changed files with 15 additions and 3 deletions

View file

@ -22,7 +22,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
public class BCLibNetherBiomeSource extends BiomeSource {
public class BCLibNetherBiomeSource extends BiomeSource {
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
return instance.group(RegistryLookupCodec.create(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> {
return theEndBiomeSource.biomeRegistry;
@ -33,6 +33,18 @@ public class BCLibNetherBiomeSource extends BiomeSource {
private final Registry<Biome> biomeRegistry;
private BiomeMap biomeMap;
private final long seed;
private static boolean forceLegacyGenerator = false;
/**
* When true, the older square generator is used for the nether.
*
* This override is used (for example) by BetterNether to force the legacy generation for worlds
* that were created before 1.18
* @param val wether or not you want to force the old generatore.
*/
public static void setForceLegacyGeneration(boolean val){
forceLegacyGenerator = val;
}
@Deprecated(forRemoval = true)
public static final List<Consumer<BCLibNetherBiomeSource>> onInit = new LinkedList<>();
@ -65,7 +77,7 @@ public class BCLibNetherBiomeSource extends BiomeSource {
BiomeAPI.NETHER_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
BiomeAPI.NETHER_BIOME_PICKER.rebuild();
if (GeneratorOptions.useOldBiomeGenerator()) {
if (GeneratorOptions.useOldBiomeGenerator() || forceLegacyGenerator) {
this.biomeMap = new SquareBiomeMap(seed, GeneratorOptions.getBiomeSizeNether(), BiomeAPI.NETHER_BIOME_PICKER);
}
else {

View file

@ -16,7 +16,7 @@ public class GeneratorOptions {
private static boolean customEndBiomeSource = true;
private static boolean addNetherBiomesByCategory = false;
private static boolean addEndBiomesByCategory = false;
private static boolean useOldBiomeGenerator = false;
private static boolean useOldBiomeGenerator = false;
public static void init() {
biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256);