[Feature] Ensure consisten feature sorting for Biomes from other sources.
This commit is contained in:
parent
c429ee3a38
commit
e3c7b00758
3 changed files with 36 additions and 6 deletions
|
@ -606,7 +606,10 @@ public class BiomeAPI {
|
|||
* @param biome The {@link Biome} to sort the features for
|
||||
*/
|
||||
public static void sortBiomeFeatures(Holder<Biome> biome) {
|
||||
BiomeGenerationSettings settings = biome.value().getGenerationSettings();
|
||||
sortBiomeFeatures(biome.value());
|
||||
}
|
||||
static void sortBiomeFeatures(Biome biome) {
|
||||
BiomeGenerationSettings settings = biome.getGenerationSettings();
|
||||
BiomeGenerationSettingsAccessor accessor = (BiomeGenerationSettingsAccessor) settings;
|
||||
List<HolderSet<PlacedFeature>> featureList = CollectionsUtil.getMutable(accessor.bclib_getFeatures());
|
||||
final int size = featureList.size();
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider;
|
|||
import org.betterx.bclib.interfaces.SurfaceRuleProvider;
|
||||
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
|
@ -21,13 +22,17 @@ import net.minecraft.world.level.dimension.LevelStem;
|
|||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
|
||||
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
|
||||
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
|
||||
import net.fabricmc.fabric.impl.registry.sync.FabricRegistry;
|
||||
import net.fabricmc.fabric.impl.registry.sync.FabricRegistryInit;
|
||||
import net.fabricmc.fabric.impl.resource.loader.FabricLifecycledResourceManager;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -74,6 +79,12 @@ public class InternalBiomeAPI {
|
|||
if (biomeRegistry != InternalBiomeAPI.biomeRegistry) {
|
||||
InternalBiomeAPI.biomeRegistry = biomeRegistry;
|
||||
CLIENT.clear();
|
||||
|
||||
BIOMES_TO_SORT.forEach(id -> {
|
||||
Biome b = biomeRegistry.get(id);
|
||||
BCLib.LOGGER.info("Sorting Features in Biome: " + id + "("+b+")");
|
||||
BiomeAPI.sortBiomeFeatures(b);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,4 +240,20 @@ public class InternalBiomeAPI {
|
|||
|
||||
BiomeAPI.sortBiomeFeatures(biome);
|
||||
}
|
||||
|
||||
private static final Set<ResourceLocation> BIOMES_TO_SORT = Sets.newHashSet();
|
||||
static {
|
||||
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
||||
Optional<? extends Registry<Biome>> oBiomeRegistry = registryManager.registry(Registry.BIOME_REGISTRY);
|
||||
RegistryEntryAddedCallback
|
||||
.event(oBiomeRegistry.get())
|
||||
.register((rawId, id, biome) -> {
|
||||
BCLBiome b = BiomeAPI.getBiome(id);
|
||||
if (!"minecraft".equals(id.getNamespace()) && (b==null || b==BiomeAPI.EMPTY_BIOME)) {
|
||||
//BCLib.LOGGER.info(" #### " + rawId + ", " + biome + ", " + id);
|
||||
BIOMES_TO_SORT.add(id);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public class MainConfig extends NamedPathConfig {
|
|||
|
||||
@ConfigUI(leftPadding = 8)
|
||||
public static final ConfigToken<Boolean> REPAIR_BIOMES = DependendConfigToken.Boolean(
|
||||
true,
|
||||
false,
|
||||
"repairBiomesOnLoad",
|
||||
Configs.MAIN_PATCH_CATEGORY,
|
||||
(config) -> config.get(
|
||||
|
|
Loading…
Reference in a new issue