From 63946e049da84494667b9a9b75c5f349829eabab Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Thu, 30 Dec 2021 11:44:15 +0300 Subject: [PATCH] Biome modification fix --- gradle.properties | 2 +- .../java/ru/bclib/api/biomes/BiomeAPI.java | 70 ++----------------- .../bclib/mixin/common/ServerLevelMixin.java | 1 - 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5ac5d5a2..4b053b9b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ loader_version= 0.12.12 fabric_version = 0.44.0+1.18 # Mod Properties -mod_version = 1.2.0 +mod_version = 1.2.1 maven_group = ru.bclib archives_base_name = bclib diff --git a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java index 5807cdf3..25d57eb2 100644 --- a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java @@ -154,16 +154,6 @@ public class BiomeAPI { 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); - }); } } @@ -193,33 +183,6 @@ public class BiomeAPI { NOISE_GENERATOR_SETTINGS.clear(); } - /** - * Registered by {@link #initRegistry(Registry)} as a callback for whenever a new Biome was - * added to our registry - * @param biome The {@link Biome} that got added - */ - private static void onAddedBiome(Biome biome) { - boolean didChange = false; - //BCLib.LOGGER.info(" ++++ " + getBiomeID(biome) + ", " + getBiomeKey(biome) + ", " + biome); - for (var dim : MODIFICATIONS.keySet()) { - List> modifications = MODIFICATIONS.get(dim); - if (modifications == null) { - sortBiomeFeatures(biome); - continue; - } - - didChange=true; - applyModificationsToBiome(modifications, biome); - } - -// if (didChange) { -// worldSources.stream() -// .filter(s -> s.possibleBiomes() -// .contains(biome)) -// .forEach(s -> ((BiomeSourceAccessor) s).bclRebuildFeatures()); -// } - } - /** * Register {@link BCLBiome} instance and its {@link Biome} if necessary. * @param biome {@link BCLBiome} @@ -612,9 +575,10 @@ public class BiomeAPI { } private static List getRuleSources(Set biomes) { - Set biomeIDs = biomes.stream() - .map(biome -> getBiomeID(biome)) - .collect(Collectors.toSet()); + Set biomeIDs = biomes + .stream() + .map(biome -> getBiomeID(biome)) + .collect(Collectors.toSet()); return getRuleSourcesFromIDs(biomeIDs); } @@ -634,29 +598,6 @@ public class BiomeAPI { } }); - // Try handle biomes from other dimension, may work not as expected - // Will not work - /*Optional optional = biomes - .stream() - .filter(biome -> biome.getBiomeCategory() != BiomeCategory.THEEND && biome.getBiomeCategory() != BiomeCategory.NETHER) - .findAny(); - if (optional.isPresent()) { - rules.add(SurfaceRuleData.overworld()); - } - - if (dimensionType == Level.NETHER) { - optional = biomes.stream().filter(biome -> biome.getBiomeCategory() != BiomeCategory.THEEND).findAny(); - if (optional.isPresent()) { - rules.add(SurfaceRuleData.end()); - } - } - else if (dimensionType == Level.END) { - optional = biomes.stream().filter(biome -> biome.getBiomeCategory() != BiomeCategory.NETHER).findAny(); - if (optional.isPresent()) { - rules.add(SurfaceRuleData.end()); - } - }*/ - return rules; } @@ -702,8 +643,7 @@ public class BiomeAPI { /** * For internal use only! * - * Adds new features to existing biome. Called from {@link BCLBiome#setFeatures(Map)} when the Biome is - * first built, and from {@link #onAddedBiome(Biome)} whenever a Biome is readded through a Datapack + * Adds new features to existing biome. Called from {@link BCLBiome#setFeatures(Map)} when the Biome is first built * @param biome {@link Biome} to add features in. * @param featureMap Map of {@link ConfiguredFeature} to add. */ diff --git a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java index 4d2ecd5b..1bd6050d 100644 --- a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java +++ b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java @@ -37,7 +37,6 @@ public abstract class ServerLevelMixin extends Level { ServerLevel level = ServerLevel.class.cast(this); LifeCycleAPI._runLevelLoad(level, server, executor, levelStorageAccess, serverLevelData, resourceKey, dimensionType, chunkProgressListener, chunkGenerator, bl, l, list, bl2); - //BiomeAPI.initRegistry(server); BiomeAPI.applyModifications(ServerLevel.class.cast(this)); if (level.dimension() == Level.NETHER) {