diff --git a/src/main/java/org/betterx/bclib/api/v2/generator/BCLBiomeSource.java b/src/main/java/org/betterx/bclib/api/v2/generator/BCLBiomeSource.java index 6e01ee27..8c406bb8 100644 --- a/src/main/java/org/betterx/bclib/api/v2/generator/BCLBiomeSource.java +++ b/src/main/java/org/betterx/bclib/api/v2/generator/BCLBiomeSource.java @@ -1,6 +1,7 @@ package org.betterx.bclib.api.v2.generator; import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI; +import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry; import org.betterx.worlds.together.biomesource.MergeableBiomeSource; import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings; import org.betterx.worlds.together.world.BiomeSourceWithSeed; @@ -18,7 +19,7 @@ import java.util.Comparator; import java.util.List; import java.util.Set; -public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource, BiomeSourceWithNoiseRelatedSettings { +public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource, BiomeSourceWithNoiseRelatedSettings, BiomeSourceFromRegistry { protected final Registry biomeRegistry; protected long currentSeed; protected int maxHeight; @@ -117,4 +118,7 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW this.setMaxHeight(generator.noiseSettings().height()); } + public Registry getBiomeRegistry() { + return biomeRegistry; + } } diff --git a/src/main/java/org/betterx/worlds/together/biomesource/BiomeSourceFromRegistry.java b/src/main/java/org/betterx/worlds/together/biomesource/BiomeSourceFromRegistry.java new file mode 100644 index 00000000..dd908026 --- /dev/null +++ b/src/main/java/org/betterx/worlds/together/biomesource/BiomeSourceFromRegistry.java @@ -0,0 +1,26 @@ +package org.betterx.worlds.together.biomesource; + +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.world.level.biome.Biome; + +import java.util.Set; + +public interface BiomeSourceFromRegistry { + Registry getBiomeRegistry(); + Set> possibleBiomes(); + + default boolean sameRegistryButDifferentBiomes(BiomeSourceFromRegistry other) { + if (other.getBiomeRegistry() == getBiomeRegistry()) { + Set> mySet = this.possibleBiomes(); + Set> otherSet = other.possibleBiomes(); + if (otherSet.size() != mySet.size()) return true; + for (Holder b : mySet) { + if (!otherSet.contains(b)) + return true; + } + } + + return false; + } +} diff --git a/src/main/java/org/betterx/worlds/together/chunkgenerator/EnforceableChunkGenerator.java b/src/main/java/org/betterx/worlds/together/chunkgenerator/EnforceableChunkGenerator.java index f43e5ed5..505b3bbb 100644 --- a/src/main/java/org/betterx/worlds/together/chunkgenerator/EnforceableChunkGenerator.java +++ b/src/main/java/org/betterx/worlds/together/chunkgenerator/EnforceableChunkGenerator.java @@ -1,5 +1,6 @@ package org.betterx.worlds.together.chunkgenerator; +import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry; import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig; import net.minecraft.core.RegistryAccess; @@ -28,8 +29,14 @@ public interface EnforceableChunkGenerator { if (one == two) return false; if (one instanceof BiomeSourceWithConfig ba && two instanceof BiomeSourceWithConfig bb) { - return !ba.getTogetherConfig().couldSetWithoutRepair(bb.getTogetherConfig()); + if (!ba.getTogetherConfig().couldSetWithoutRepair(bb.getTogetherConfig())) + return true; } + if (one instanceof BiomeSourceFromRegistry ba && two instanceof BiomeSourceFromRegistry bb) { + if (ba.sameRegistryButDifferentBiomes(bb)) + return true; + } + return !one.getClass().isAssignableFrom(two.getClass()) && !two.getClass().isAssignableFrom(one.getClass()); } }