Biome modification fix

This commit is contained in:
paulevsGitch 2021-12-30 11:44:15 +03:00
parent 9622fd393c
commit 63946e049d
3 changed files with 6 additions and 67 deletions

View file

@ -11,7 +11,7 @@ loader_version= 0.12.12
fabric_version = 0.44.0+1.18 fabric_version = 0.44.0+1.18
# Mod Properties # Mod Properties
mod_version = 1.2.0 mod_version = 1.2.1
maven_group = ru.bclib maven_group = ru.bclib
archives_base_name = bclib archives_base_name = bclib

View file

@ -154,16 +154,6 @@ public class BiomeAPI {
if (biomeRegistry != BiomeAPI.biomeRegistry) { if (biomeRegistry != BiomeAPI.biomeRegistry) {
BiomeAPI.biomeRegistry = biomeRegistry; BiomeAPI.biomeRegistry = biomeRegistry;
CLIENT.clear(); 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(); 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<BiConsumer<ResourceLocation, Biome>> 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. * Register {@link BCLBiome} instance and its {@link Biome} if necessary.
* @param biome {@link BCLBiome} * @param biome {@link BCLBiome}
@ -612,9 +575,10 @@ public class BiomeAPI {
} }
private static List<SurfaceRules.RuleSource> getRuleSources(Set<Biome> biomes) { private static List<SurfaceRules.RuleSource> getRuleSources(Set<Biome> biomes) {
Set<ResourceLocation> biomeIDs = biomes.stream() Set<ResourceLocation> biomeIDs = biomes
.map(biome -> getBiomeID(biome)) .stream()
.collect(Collectors.toSet()); .map(biome -> getBiomeID(biome))
.collect(Collectors.toSet());
return getRuleSourcesFromIDs(biomeIDs); 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<Biome> 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; return rules;
} }
@ -702,8 +643,7 @@ public class BiomeAPI {
/** /**
* For internal use only! * For internal use only!
* *
* Adds new features to existing biome. Called from {@link BCLBiome#setFeatures(Map)} when the Biome is * Adds new features to existing biome. Called from {@link BCLBiome#setFeatures(Map)} when the Biome is first built
* first built, and from {@link #onAddedBiome(Biome)} whenever a Biome is readded through a Datapack
* @param biome {@link Biome} to add features in. * @param biome {@link Biome} to add features in.
* @param featureMap Map of {@link ConfiguredFeature} to add. * @param featureMap Map of {@link ConfiguredFeature} to add.
*/ */

View file

@ -37,7 +37,6 @@ public abstract class ServerLevelMixin extends Level {
ServerLevel level = ServerLevel.class.cast(this); ServerLevel level = ServerLevel.class.cast(this);
LifeCycleAPI._runLevelLoad(level, server, executor, levelStorageAccess, serverLevelData, resourceKey, dimensionType, chunkProgressListener, chunkGenerator, bl, l, list, bl2); LifeCycleAPI._runLevelLoad(level, server, executor, levelStorageAccess, serverLevelData, resourceKey, dimensionType, chunkProgressListener, chunkGenerator, bl, l, list, bl2);
//BiomeAPI.initRegistry(server);
BiomeAPI.applyModifications(ServerLevel.class.cast(this)); BiomeAPI.applyModifications(ServerLevel.class.cast(this));
if (level.dimension() == Level.NETHER) { if (level.dimension() == Level.NETHER) {