From 43f6d72dda28dbc5188f415ca56da8be375a2362 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 15 Dec 2021 20:47:57 +0100 Subject: [PATCH] Make sure features are applied to the correct biomes --- .../java/ru/bclib/api/biomes/BiomeAPI.java | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java index 839dbe78..eba16264 100644 --- a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java @@ -140,8 +140,34 @@ public class BiomeAPI { * @param biomeRegistry - {@link Registry} for {@link Biome}. */ public static void initRegistry(Registry biomeRegistry) { - BiomeAPI.biomeRegistry = biomeRegistry; - CLIENT.clear(); + if (biomeRegistry != BiomeAPI.biomeRegistry) { + BiomeAPI.biomeRegistry = biomeRegistry; + CLIENT.clear(); + + for (var entry : biomeRegistry.entrySet()){ + onAddedBiome(entry.getValue()); + } + RegistryEntryAddedCallback + .event(biomeRegistry) + .register((rawId, id, biome)->{ + + BCLib.LOGGER.info(" #### " + rawId + ", " + biome + ", " + id); + + onAddedBiome(biome); + }); + } + } + + private static void onAddedBiome(Biome biome) { + for (var dim : MODIFICATIONS.keySet()) { + List> modifications = MODIFICATIONS.get(dim); + if (modifications == null) { + sortBiomeFeatures(biome); + return; + } + + applyModifications(modifications, biome); + } } /** @@ -821,6 +847,10 @@ public class BiomeAPI { DynamicRegistrySetupCallback.EVENT.register(registryManager -> { Optional> oGeneratorRegistry = registryManager.registry(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); Optional> oBiomeRegistry = registryManager.registry(Registry.BIOME_REGISTRY); + if (oBiomeRegistry.isPresent()){ + + + } if (oGeneratorRegistry.isPresent()) { RegistryEntryAddedCallback @@ -841,23 +871,7 @@ public class BiomeAPI { }); } - if (oBiomeRegistry.isPresent()){ - RegistryEntryAddedCallback - .event(oBiomeRegistry.get()) - .register((rawId, id, biome)->{ - //BCLib.LOGGER.info(" #### " + rawId + ", " + biome + ", " + id); - - for (var dim : MODIFICATIONS.keySet()) { - List> modifications = MODIFICATIONS.get(dim); - if (modifications == null) { - sortBiomeFeatures(biome); - return; - } - - applyModifications(modifications, biome); - } - }); - } + }); }