[Change] Prevent Crash when merging BiomeSources. A cought crash can result in modded biomes not getting loaded. (quiqueck/BetterNether#138)
This commit is contained in:
parent
f0dd0e698d
commit
fd9bac7484
2 changed files with 33 additions and 18 deletions
|
@ -238,24 +238,30 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
||||||
final List<String> excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(defaultBiomeType());
|
final List<String> excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(defaultBiomeType());
|
||||||
final Registry<BCLBiome> bclBiomes = access.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
final Registry<BCLBiome> bclBiomes = access.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||||
|
|
||||||
for (Holder<Biome> possibleBiome : inputBiomeSource.possibleBiomes()) {
|
try {
|
||||||
ResourceKey<Biome> key = possibleBiome.unwrapKey().orElse(null);
|
for (Holder<Biome> possibleBiome : inputBiomeSource.possibleBiomes()) {
|
||||||
if (key != null) {
|
ResourceKey<Biome> key = possibleBiome.unwrapKey().orElse(null);
|
||||||
//skip over all biomes that were excluded in the config
|
if (key != null) {
|
||||||
if (excludeList.contains(key.location())) continue;
|
//skip over all biomes that were excluded in the config
|
||||||
|
if (excludeList.contains(key.location())) continue;
|
||||||
|
|
||||||
//this is a biome that has no type entry => create a new one for the default type of this registry
|
//this is a biome that has no type entry => create a new one for the default type of this registry
|
||||||
if (!BCLBiomeRegistry.hasBiome(key, bclBiomes)) {
|
if (!BCLBiomeRegistry.hasBiome(key, bclBiomes)) {
|
||||||
BiomeAPI.BiomeType type = typeForUnknownBiome(key, defaultBiomeType());
|
BiomeAPI.BiomeType type = typeForUnknownBiome(key, defaultBiomeType());
|
||||||
|
|
||||||
//check if there was an override defined in the configs
|
//check if there was an override defined in the configs
|
||||||
type = getBiomeType(includeMap, key, type);
|
type = getBiomeType(includeMap, key, type);
|
||||||
|
|
||||||
//create and register a biome wrapper
|
//create and register a biome wrapper
|
||||||
BCLBiome bclBiome = new BCLBiome(key.location(), type);
|
BCLBiome bclBiome = new BCLBiome(key.location(), type);
|
||||||
BCLBiomeRegistry.register(bclBiome);
|
BCLBiomeRegistry.register(bclBiome);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
BCLib.LOGGER.error("Error while rebuilding Biomesources!", e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
BCLib.LOGGER.error("Error while rebuilding Biomesources!", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.reloadBiomes();
|
this.reloadBiomes();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.betterx.worlds.together.biomesource;
|
package org.betterx.worlds.together.biomesource;
|
||||||
|
|
||||||
|
import org.betterx.bclib.BCLib;
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
|
@ -9,12 +11,19 @@ import java.util.Set;
|
||||||
public interface MergeableBiomeSource<B extends BiomeSource> {
|
public interface MergeableBiomeSource<B extends BiomeSource> {
|
||||||
default boolean togetherShouldMerge(BiomeSource inputBiomeSource) {
|
default boolean togetherShouldMerge(BiomeSource inputBiomeSource) {
|
||||||
Set<Holder<Biome>> mySet = ((B) this).possibleBiomes();
|
Set<Holder<Biome>> mySet = ((B) this).possibleBiomes();
|
||||||
Set<Holder<Biome>> otherSet = inputBiomeSource.possibleBiomes();
|
try {
|
||||||
if (otherSet.size() != mySet.size()) return true;
|
Set<Holder<Biome>> otherSet = inputBiomeSource.possibleBiomes();
|
||||||
|
|
||||||
for (Holder<Biome> b : mySet) {
|
if (otherSet.size() != mySet.size()) return true;
|
||||||
if (!otherSet.contains(b))
|
|
||||||
return true;
|
for (Holder<Biome> b : mySet) {
|
||||||
|
if (!otherSet.contains(b))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
BCLib.LOGGER.error("Failed to merge BiomeSource", e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
BCLib.LOGGER.error("Failed to merge BiomeSource", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue