From c6dc52a60d4ab36a33403b6a27e2c3e860c412f4 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 3 Dec 2021 00:31:53 +0100 Subject: [PATCH] override for the nether biome generator that is used by BN when older worlds are loaded --- .../world/generator/BCLibNetherBiomeSource.java | 16 ++++++++++++++-- .../bclib/world/generator/GeneratorOptions.java | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java index 9e524341..044e4c99 100644 --- a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java @@ -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 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 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> 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 { diff --git a/src/main/java/ru/bclib/world/generator/GeneratorOptions.java b/src/main/java/ru/bclib/world/generator/GeneratorOptions.java index 76032ab9..8cdf8911 100644 --- a/src/main/java/ru/bclib/world/generator/GeneratorOptions.java +++ b/src/main/java/ru/bclib/world/generator/GeneratorOptions.java @@ -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);