Skip to content

Commit

Permalink
Fix crash when biomes have been disabled via modloader methods. (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug authored May 28, 2024
1 parent 067e8c8 commit 94d2528
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public void initializeForTerraBlender(RegistryAccess registryAccess, RegionType
else
{
ImmutableList.Builder<Pair<Climate.ParameterPoint, Holder<Biome>>> builder = ImmutableList.builder();
region.addBiomes(biomeRegistry, pair -> builder.add(pair.mapSecond(biomeRegistry::getHolderOrThrow)));
region.addBiomes(biomeRegistry, pair -> {
if (biomeRegistry.getHolder(pair.getSecond()).isPresent())
builder.add(pair.mapSecond(biomeRegistry::getHolderOrThrow));
});
ImmutableList<Pair<Climate.ParameterPoint, Holder<Biome>>> uniqueValues = builder.build();

// We can't create an RTree if there are no values present.
Expand Down
5 changes: 4 additions & 1 deletion Common/src/main/java/terrablender/util/LevelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public static void initializeBiomes(RegistryAccess registryAccess, Holder<Dimens
// Append modded biomes to the biome source biome list
Registry<Biome> biomeRegistry = registryAccess.registryOrThrow(Registries.BIOME);
ImmutableList.Builder<Holder<Biome>> builder = ImmutableList.builder();
Regions.get(regionType).forEach(region -> region.addBiomes(biomeRegistry, pair -> builder.add(biomeRegistry.getHolderOrThrow(pair.getSecond()))));
Regions.get(regionType).forEach(region -> region.addBiomes(biomeRegistry, pair -> {
if (biomeRegistry.getHolder(pair.getSecond()).isPresent())
builder.add(biomeRegistry.getHolderOrThrow(pair.getSecond()));
}));
biomeSourceEx.appendDeferredBiomesList(builder.build());

TerraBlender.LOGGER.info(String.format("Initialized TerraBlender biomes for level stem %s", levelResourceKey.location()));
Expand Down

0 comments on commit 94d2528

Please sign in to comment.