[Changes] BCLBiomeSource
relies more on BCLRegistry
This commit is contained in:
parent
a592c05b4d
commit
561fc130a3
12 changed files with 723 additions and 454 deletions
|
@ -2,62 +2,68 @@ package org.betterx.bclib.api.v2.generator;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceHelper;
|
||||
import org.betterx.worlds.together.biomesource.MergeableBiomeSource;
|
||||
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
||||
import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
||||
import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource<BCLBiomeSource>, BiomeSourceWithNoiseRelatedSettings, BiomeSourceFromRegistry<BCLBiomeSource> {
|
||||
protected final HolderGetter<Biome> biomeRegistry;
|
||||
protected final HolderGetter<BCLBiome> bclBiomeRegistry;
|
||||
private int registryModificationCounter;
|
||||
protected long currentSeed;
|
||||
protected int maxHeight;
|
||||
|
||||
private static List<Holder<Biome>> preInit(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
List<Holder<Biome>> biomes
|
||||
) {
|
||||
biomes = biomes.stream().sorted(Comparator.comparing(holder -> holder.unwrapKey()
|
||||
.get()
|
||||
.location()
|
||||
.toString()))
|
||||
.toList();
|
||||
return biomes;
|
||||
public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource<BCLBiomeSource>, BiomeSourceWithNoiseRelatedSettings, ReloadableBiomeSource, BiomeSourceFromRegistry<BCLBiomeSource> {
|
||||
@FunctionalInterface
|
||||
public interface PickerAdder {
|
||||
boolean add(BCLBiome bclBiome, BiomeAPI.BiomeType type, BiomePicker picker);
|
||||
}
|
||||
|
||||
protected BCLBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed
|
||||
) {
|
||||
super(preInit(biomeRegistry, list));
|
||||
this.registryModificationCounter = InternalBiomeAPI.getBiomeRegistryModificationCount(biomeRegistry);
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
this.bclBiomeRegistry = bclBiomeRegistry;
|
||||
@FunctionalInterface
|
||||
public interface CustomTypeFinder {
|
||||
BiomeAPI.BiomeType find(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType defaultType);
|
||||
}
|
||||
|
||||
protected long currentSeed;
|
||||
protected int maxHeight;
|
||||
private boolean didCreatePickers;
|
||||
Set<Holder<Biome>> dynamicPossibleBiomes;
|
||||
|
||||
protected BCLBiomeSource(long seed) {
|
||||
super(List.of());
|
||||
this.dynamicPossibleBiomes = Set.of();
|
||||
this.currentSeed = seed;
|
||||
this.didCreatePickers = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Holder<Biome>> possibleBiomes() {
|
||||
return dynamicPossibleBiomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean didBiomeRegistryChange() {
|
||||
return this.registryModificationCounter != InternalBiomeAPI.getBiomeRegistryModificationCount(biomeRegistry);
|
||||
return false;
|
||||
//return this.registryModificationCounter != InternalBiomeAPI.getBiomeRegistryModificationCount(biomeRegistry);
|
||||
}
|
||||
|
||||
protected boolean wasBound() {
|
||||
return didCreatePickers;
|
||||
}
|
||||
|
||||
final public void setSeed(long seed) {
|
||||
|
@ -102,52 +108,168 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
return BiomeSourceHelper.getNamespaces(possibleBiomes());
|
||||
}
|
||||
|
||||
public interface ValidBiomePredicate {
|
||||
boolean isValid(Holder<Biome> biome, ResourceLocation location);
|
||||
// public interface ValidBiomePredicate {
|
||||
// boolean isValid(Holder<Biome> biome, ResourceLocation location);
|
||||
// }
|
||||
|
||||
protected boolean addToPicker(BCLBiome bclBiome, BiomeAPI.BiomeType type, BiomePicker picker) {
|
||||
picker.addBiome(bclBiome);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static List<Holder<Biome>> getBiomes(
|
||||
HolderGetter<Biome> getter,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
List<String> exclude,
|
||||
List<String> include,
|
||||
BCLibNetherBiomeSource.ValidBiomePredicate test
|
||||
protected BiomeAPI.BiomeType typeForUnknownBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType defaultType) {
|
||||
return defaultType;
|
||||
}
|
||||
|
||||
|
||||
protected static Set<Holder<Biome>> populateBiomePickers(
|
||||
Map<BiomeAPI.BiomeType, BiomePicker> acceptedBiomeTypes,
|
||||
BiomeAPI.BiomeType exclusionListType,
|
||||
PickerAdder pickerAdder,
|
||||
CustomTypeFinder typeFinder
|
||||
) {
|
||||
Optional<Field> res = Arrays.stream(getter.getClass().getFields())
|
||||
.filter(f -> Registry.class.isAssignableFrom(f.getType()))
|
||||
.findFirst();
|
||||
if (res.isPresent()) {
|
||||
try {
|
||||
Registry<Biome> biomeRegistry = (Registry<Biome>) res.get().get(getter);
|
||||
final RegistryAccess access = WorldBootstrap.getLastRegistryAccess();
|
||||
if (access == null) {
|
||||
BCLib.LOGGER.info("Unable to build Biome List yet");
|
||||
return null;
|
||||
}
|
||||
|
||||
return biomeRegistry.stream()
|
||||
.filter(biome -> biomeRegistry.getResourceKey(biome).isPresent())
|
||||
.map(biome -> (Holder<Biome>) biomeRegistry.getHolderOrThrow(
|
||||
biomeRegistry.getResourceKey(biome).get())
|
||||
)
|
||||
.filter(biome -> {
|
||||
ResourceLocation location = biome.unwrapKey().orElseThrow().location();
|
||||
final String strLocation = location.toString();
|
||||
if (exclude.contains(strLocation)) return false;
|
||||
if (include.contains(strLocation)) return true;
|
||||
final Set<Holder<Biome>> allBiomes = new HashSet<>();
|
||||
final Map<BiomeAPI.BiomeType, List<String>> includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
|
||||
final List<String> excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(exclusionListType);
|
||||
final Registry<Biome> biomes = access.registryOrThrow(Registries.BIOME);
|
||||
final Registry<BCLBiome> bclBiomes = access.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
|
||||
return test.isValid(biome, location);
|
||||
})
|
||||
final List<Map.Entry<ResourceKey<Biome>, Biome>> sortedList = biomes
|
||||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(a -> a.getKey().location().toString()))
|
||||
.toList();
|
||||
} catch (IllegalAccessException e) {
|
||||
BCLib.LOGGER.error("Unable to load field", e);
|
||||
return List.of();
|
||||
}
|
||||
|
||||
for (Map.Entry<ResourceKey<Biome>, Biome> biomeEntry : sortedList) {
|
||||
if (excludeList.contains(biomeEntry.getKey().location())) continue;
|
||||
|
||||
BiomeAPI.BiomeType type = BiomeAPI.BiomeType.NONE;
|
||||
boolean foundBCLBiome = false;
|
||||
if (BCLBiomeRegistry.hasBiome(biomeEntry.getKey(), bclBiomes)) {
|
||||
foundBCLBiome = true;
|
||||
type = BCLBiomeRegistry.getBiome(biomeEntry.getKey(), bclBiomes).getIntendedType();
|
||||
} else {
|
||||
BCLib.LOGGER.error("Unable to access Biome Registry..");
|
||||
return List.of();
|
||||
type = typeFinder.find(biomeEntry.getKey(), type);
|
||||
}
|
||||
|
||||
type = getBiomeType(includeMap, biomeEntry.getKey(), type);
|
||||
|
||||
for (Map.Entry<BiomeAPI.BiomeType, BiomePicker> pickerEntry : acceptedBiomeTypes.entrySet()) {
|
||||
if (type.is(pickerEntry.getKey())) {
|
||||
BCLBiome bclBiome;
|
||||
if (foundBCLBiome) {
|
||||
bclBiome = BCLBiomeRegistry.getBiome(biomeEntry.getKey(), bclBiomes);
|
||||
} else {
|
||||
//create and register a biome wrapper
|
||||
bclBiome = new BCLBiome(biomeEntry.getKey().location(), type);
|
||||
BCLBiomeRegistry.register(bclBiome);
|
||||
foundBCLBiome = true;
|
||||
}
|
||||
|
||||
boolean didAdd = false;
|
||||
if (!bclBiome.hasParentBiome()) {
|
||||
didAdd = pickerAdder.add(bclBiome, pickerEntry.getKey(), pickerEntry.getValue());
|
||||
}
|
||||
|
||||
if (didAdd) {
|
||||
allBiomes.add(biomes.getHolderOrThrow(biomeEntry.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return allBiomes;
|
||||
}
|
||||
|
||||
protected abstract BiomeAPI.BiomeType defaultBiomeType();
|
||||
protected abstract Map<BiomeAPI.BiomeType, BiomePicker> createFreshPickerMap();
|
||||
|
||||
public abstract String toShortString();
|
||||
|
||||
protected void onFinishBiomeRebuild(Map<BiomeAPI.BiomeType, BiomePicker> pickerMap) {
|
||||
for (var picker : pickerMap.values()) {
|
||||
picker.rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
protected final void rebuildBiomes(boolean force) {
|
||||
if (!force && didCreatePickers) return;
|
||||
|
||||
if (Configs.MAIN_CONFIG.verboseLogging()) {
|
||||
BCLib.LOGGER.info("Updating Pickers for " + this.toShortString());
|
||||
}
|
||||
|
||||
Map<BiomeAPI.BiomeType, BiomePicker> pickerMap = createFreshPickerMap();
|
||||
this.dynamicPossibleBiomes = populateBiomePickers(
|
||||
pickerMap,
|
||||
defaultBiomeType(),
|
||||
this::addToPicker,
|
||||
this::typeForUnknownBiome
|
||||
);
|
||||
if (this.dynamicPossibleBiomes == null) {
|
||||
this.dynamicPossibleBiomes = Set.of();
|
||||
} else {
|
||||
this.didCreatePickers = true;
|
||||
}
|
||||
|
||||
onFinishBiomeRebuild(pickerMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BCLBiomeSource mergeWithBiomeSource(BiomeSource inputBiomeSource) {
|
||||
final Set<Holder<Biome>> datapackBiomes = inputBiomeSource.possibleBiomes();
|
||||
return this.createCopyForDatapack(datapackBiomes);
|
||||
final RegistryAccess access = WorldBootstrap.getLastRegistryAccess();
|
||||
if (access == null) {
|
||||
BCLib.LOGGER.error("Unable to merge Biomesources!");
|
||||
return this;
|
||||
}
|
||||
|
||||
final Map<BiomeAPI.BiomeType, List<String>> includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
|
||||
final List<String> excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(defaultBiomeType());
|
||||
final Registry<BCLBiome> bclBiomes = access.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
|
||||
for (Holder<Biome> possibleBiome : inputBiomeSource.possibleBiomes()) {
|
||||
ResourceKey<Biome> key = possibleBiome.unwrapKey().orElse(null);
|
||||
if (key != null) {
|
||||
//skip over all biomes that were excluded in the config
|
||||
if (excludeList.contains(key.location())) continue;
|
||||
|
||||
//this is a biome that has no type entry => create a new one for the default type of this registry
|
||||
if (!BCLBiomeRegistry.hasBiome(key, bclBiomes)) {
|
||||
BiomeAPI.BiomeType type = typeForUnknownBiome(key, defaultBiomeType());
|
||||
|
||||
//check if there was an override defined in the configs
|
||||
type = getBiomeType(includeMap, key, type);
|
||||
|
||||
//create and register a biome wrapper
|
||||
BCLBiome bclBiome = new BCLBiome(key.location(), type);
|
||||
BCLBiomeRegistry.register(bclBiome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.reloadBiomes();
|
||||
return this;
|
||||
}
|
||||
|
||||
private static BiomeAPI.BiomeType getBiomeType(
|
||||
Map<BiomeAPI.BiomeType, List<String>> includeMap,
|
||||
ResourceKey<Biome> biomeKey,
|
||||
BiomeAPI.BiomeType defaultType
|
||||
) {
|
||||
for (Map.Entry<BiomeAPI.BiomeType, List<String>> includeList : includeMap.entrySet()) {
|
||||
if (includeList.getValue().contains(biomeKey.location().toString())) {
|
||||
return includeList.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return defaultType;
|
||||
}
|
||||
|
||||
public void onLoadGeneratorSettings(NoiseGeneratorSettings generator) {
|
||||
|
@ -156,6 +278,17 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
|
||||
@Override
|
||||
public HolderGetter<Biome> getBiomeRegistry() {
|
||||
return biomeRegistry;
|
||||
//return biomeRegistry;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void reloadBiomes(boolean force) {
|
||||
rebuildBiomes(force);
|
||||
this.initMap(currentSeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadBiomes() {
|
||||
reloadBiomes(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,8 @@ import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
@ -28,13 +24,12 @@ import net.minecraft.world.level.biome.Climate;
|
|||
import net.minecraft.world.level.levelgen.DensityFunction;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibEndBiomeSource, BCLEndBiomeSourceConfig>, ReloadableBiomeSource {
|
||||
public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibEndBiomeSource, BCLEndBiomeSourceConfig> {
|
||||
public static Codec<BCLibEndBiomeSource> CODEC
|
||||
= RecordCodecBuilder.create((instance) -> instance
|
||||
.group(
|
||||
|
@ -94,7 +89,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
BCLEndBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
this(biomeRegistry, bclBiomeRegistry, getBiomes(biomeRegistry, bclBiomeRegistry), seed, config, initMaps);
|
||||
this(biomeRegistry, bclBiomeRegistry, null, seed, config, initMaps);
|
||||
}
|
||||
|
||||
private BCLibEndBiomeSource(
|
||||
|
@ -105,9 +100,9 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
BCLEndBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
super(biomeRegistry, bclBiomeRegistry, list, seed);
|
||||
super(seed);
|
||||
this.config = config;
|
||||
rebuildBiomePickers();
|
||||
rebuildBiomes(false);
|
||||
|
||||
this.pos = new Point();
|
||||
|
||||
|
@ -116,122 +111,68 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private void rebuildBiomePickers() {
|
||||
if (WorldBootstrap.getLastRegistryAccess() == null) {
|
||||
this.endLandBiomePicker = null;
|
||||
this.endVoidBiomePicker = null;
|
||||
this.endCenterBiomePicker = null;
|
||||
this.endBarrensBiomePicker = null;
|
||||
this.deciders = List.of();
|
||||
return;
|
||||
@Override
|
||||
protected BiomeAPI.BiomeType defaultBiomeType() {
|
||||
return BiomeAPI.BiomeType.END;
|
||||
}
|
||||
|
||||
HolderLookup.RegistryLookup<Biome> biomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
.lookupOrThrow(Registries.BIOME);
|
||||
Registry<BCLBiome> bclBiomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
|
||||
|
||||
var includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
|
||||
var excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END);
|
||||
|
||||
@Override
|
||||
protected Map<BiomeAPI.BiomeType, BiomePicker> createFreshPickerMap() {
|
||||
this.deciders = BiomeDecider.DECIDERS.stream()
|
||||
.filter(d -> d.canProvideFor(this))
|
||||
.map(d -> d.createInstance(this))
|
||||
.toList();
|
||||
|
||||
this.endLandBiomePicker = new BiomePicker(biomeRegistry);
|
||||
this.endVoidBiomePicker = new BiomePicker(biomeRegistry);
|
||||
this.endCenterBiomePicker = new BiomePicker(biomeRegistry);
|
||||
this.endBarrensBiomePicker = new BiomePicker(biomeRegistry);
|
||||
Map<BiomeAPI.BiomeType, BiomePicker> pickerMap = new HashMap<>();
|
||||
pickerMap.put(BiomeAPI.BiomeType.END_LAND, endLandBiomePicker);
|
||||
pickerMap.put(BiomeAPI.BiomeType.END_VOID, endVoidBiomePicker);
|
||||
pickerMap.put(BiomeAPI.BiomeType.END_CENTER, endCenterBiomePicker);
|
||||
pickerMap.put(BiomeAPI.BiomeType.END_BARRENS, endBarrensBiomePicker);
|
||||
this.endLandBiomePicker = new BiomePicker();
|
||||
this.endVoidBiomePicker = new BiomePicker();
|
||||
this.endCenterBiomePicker = new BiomePicker();
|
||||
this.endBarrensBiomePicker = new BiomePicker();
|
||||
|
||||
|
||||
this.possibleBiomes().forEach(biome -> {
|
||||
ResourceKey<Biome> key = biome.unwrapKey().orElseThrow();
|
||||
ResourceLocation biomeID = key.location();
|
||||
String biomeStr = biomeID.toString();
|
||||
//exclude everything that was listed
|
||||
if (excludeList != null && excludeList.contains(biomeStr)) return;
|
||||
if (!biome.isBound()) {
|
||||
BCLib.LOGGER.warning("Biome " + biomeStr + " is requested but not yet bound.");
|
||||
return;
|
||||
}
|
||||
final BCLBiome bclBiome;
|
||||
if (!bclBiomeRegistry.containsKey(biomeID)) {
|
||||
bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.END_LAND);
|
||||
InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
} else {
|
||||
bclBiome = bclBiomeRegistry.get(biomeID);
|
||||
return Map.of(
|
||||
BiomeAPI.BiomeType.END_LAND, endLandBiomePicker,
|
||||
BiomeAPI.BiomeType.END_VOID, endVoidBiomePicker,
|
||||
BiomeAPI.BiomeType.END_CENTER, endCenterBiomePicker,
|
||||
BiomeAPI.BiomeType.END_BARRENS, endBarrensBiomePicker
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!BCLBiomeRegistry.isEmptyBiome(bclBiome)) {
|
||||
if (bclBiome.getParentBiome() == null) {
|
||||
//ignore small islands when void biomes are disabled
|
||||
protected boolean addToPicker(BCLBiome bclBiome, BiomeAPI.BiomeType type, BiomePicker picker) {
|
||||
if (!config.withVoidBiomes) {
|
||||
if (biomeID.equals(Biomes.SMALL_END_ISLANDS.location())) {
|
||||
return;
|
||||
if (bclBiome.getID().equals(Biomes.SMALL_END_ISLANDS.location())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//force include biomes
|
||||
boolean didForceAdd = false;
|
||||
for (var entry : pickerMap.entrySet()) {
|
||||
var includeList = includeMap == null ? null : includeMap.get(entry.getKey());
|
||||
if (includeList != null && includeList.contains(biomeStr)) {
|
||||
entry.getValue().addBiome(bclBiome);
|
||||
didForceAdd = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!didForceAdd) {
|
||||
if (BCLBiomeRegistry.isEmptyBiome(biomeID)
|
||||
|| bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_IGNORE)) {
|
||||
//we should not add this biome anywhere, so just ignore it
|
||||
} else {
|
||||
didForceAdd = false;
|
||||
for (BiomeDecider decider : deciders) {
|
||||
if (decider.addToPicker(bclBiome)) {
|
||||
didForceAdd = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!didForceAdd) {
|
||||
if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_CENTER)
|
||||
|| TheEndBiomesHelper.canGenerateAsMainIslandBiome(key)) {
|
||||
endCenterBiomePicker.addBiome(bclBiome);
|
||||
} else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_LAND)
|
||||
|| TheEndBiomesHelper.canGenerateAsHighlandsBiome(key)) {
|
||||
if (!config.withVoidBiomes) endVoidBiomePicker.addBiome(bclBiome);
|
||||
endLandBiomePicker.addBiome(bclBiome);
|
||||
} else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_BARRENS)
|
||||
|| TheEndBiomesHelper.canGenerateAsEndBarrens(key)) {
|
||||
endBarrensBiomePicker.addBiome(bclBiome);
|
||||
} else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_VOID)
|
||||
|| TheEndBiomesHelper.canGenerateAsSmallIslandsBiome(key)) {
|
||||
endVoidBiomePicker.addBiome(bclBiome);
|
||||
} else {
|
||||
BCLib.LOGGER.info("Found End Biome " + biomeStr + " that was not registers with fabric or bclib. Assuming end-land Biome...");
|
||||
endLandBiomePicker.addBiome(bclBiome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
endLandBiomePicker.rebuild();
|
||||
endVoidBiomePicker.rebuild();
|
||||
endBarrensBiomePicker.rebuild();
|
||||
endCenterBiomePicker.rebuild();
|
||||
return super.addToPicker(bclBiome, type, picker);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BiomeAPI.BiomeType typeForUnknownBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType defaultType) {
|
||||
if (TheEndBiomesHelper.canGenerateAsMainIslandBiome(biomeKey)) {
|
||||
return BiomeAPI.BiomeType.END_CENTER;
|
||||
} else if (TheEndBiomesHelper.canGenerateAsHighlandsBiome(biomeKey)) {
|
||||
if (!config.withVoidBiomes) return BiomeAPI.BiomeType.END_VOID;
|
||||
return BiomeAPI.BiomeType.END_LAND;
|
||||
} else if (TheEndBiomesHelper.canGenerateAsEndBarrens(biomeKey)) {
|
||||
return BiomeAPI.BiomeType.END_BARRENS;
|
||||
} else if (TheEndBiomesHelper.canGenerateAsSmallIslandsBiome(biomeKey)) {
|
||||
return BiomeAPI.BiomeType.END_VOID;
|
||||
} else if (TheEndBiomesHelper.canGenerateAsEndMidlands(biomeKey)) {
|
||||
return BiomeAPI.BiomeType.END_LAND;
|
||||
}
|
||||
|
||||
return super.typeForUnknownBiome(biomeKey, defaultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishBiomeRebuild(Map<BiomeAPI.BiomeType, BiomePicker> pickerMap) {
|
||||
super.onFinishBiomeRebuild(pickerMap);
|
||||
|
||||
for (BiomeDecider decider : deciders) {
|
||||
decider.rebuild();
|
||||
|
@ -248,63 +189,206 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
}
|
||||
if (endCenterBiomePicker.isEmpty()) {
|
||||
BCLib.LOGGER.warning("No Center Island Biomes found. Forcing use of vanilla center.");
|
||||
endCenterBiomePicker.addBiome(BiomeAPI.THE_END);
|
||||
endCenterBiomePicker.addBiome(BCLBiomeRegistry.THE_END);
|
||||
endCenterBiomePicker.rebuild();
|
||||
if (endCenterBiomePicker.isEmpty()) {
|
||||
BCLib.LOGGER.error("Unable to force vanilla central Island. Falling back to land Biomes...");
|
||||
endCenterBiomePicker = endLandBiomePicker;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// @NotNull
|
||||
// private void rebuildBiomePickers() {
|
||||
// if (WorldBootstrap.getLastRegistryAccess() == null) {
|
||||
// this.endLandBiomePicker = null;
|
||||
// this.endVoidBiomePicker = null;
|
||||
// this.endCenterBiomePicker = null;
|
||||
// this.endBarrensBiomePicker = null;
|
||||
// this.deciders = List.of();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// HolderLookup.RegistryLookup<Biome> biomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
// .lookupOrThrow(Registries.BIOME);
|
||||
// Registry<BCLBiome> bclBiomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
// .registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
//
|
||||
//
|
||||
// var includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
|
||||
// var excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END);
|
||||
//
|
||||
// this.deciders = BiomeDecider.DECIDERS.stream()
|
||||
// .filter(d -> d.canProvideFor(this))
|
||||
// .map(d -> d.createInstance(this))
|
||||
// .toList();
|
||||
//
|
||||
// this.endLandBiomePicker = new BiomePicker(biomeRegistry);
|
||||
// this.endVoidBiomePicker = new BiomePicker(biomeRegistry);
|
||||
// this.endCenterBiomePicker = new BiomePicker(biomeRegistry);
|
||||
// this.endBarrensBiomePicker = new BiomePicker(biomeRegistry);
|
||||
// Map<BiomeAPI.BiomeType, BiomePicker> pickerMap = new HashMap<>();
|
||||
// pickerMap.put(BiomeAPI.BiomeType.END_LAND, endLandBiomePicker);
|
||||
// pickerMap.put(BiomeAPI.BiomeType.END_VOID, endVoidBiomePicker);
|
||||
// pickerMap.put(BiomeAPI.BiomeType.END_CENTER, endCenterBiomePicker);
|
||||
// pickerMap.put(BiomeAPI.BiomeType.END_BARRENS, endBarrensBiomePicker);
|
||||
//
|
||||
//
|
||||
// this.possibleBiomes().forEach(biome -> {
|
||||
// ResourceKey<Biome> key = biome.unwrapKey().orElseThrow();
|
||||
// ResourceLocation biomeID = key.location();
|
||||
// String biomeStr = biomeID.toString();
|
||||
// //exclude everything that was listed
|
||||
// if (excludeList != null && excludeList.contains(biomeStr)) return;
|
||||
// if (!biome.isBound()) {
|
||||
// BCLib.LOGGER.warning("Biome " + biomeStr + " is requested but not yet bound.");
|
||||
// return;
|
||||
// }
|
||||
// final BCLBiome bclBiome;
|
||||
// if (!bclBiomeRegistry.containsKey(biomeID)) {
|
||||
// bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.END_LAND);
|
||||
// InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
// } else {
|
||||
// bclBiome = bclBiomeRegistry.get(biomeID);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (!BCLBiomeRegistry.isEmptyBiome(bclBiome)) {
|
||||
// if (bclBiome.getParentBiome() == null) {
|
||||
// //ignore small islands when void biomes are disabled
|
||||
// if (!config.withVoidBiomes) {
|
||||
// if (biomeID.equals(Biomes.SMALL_END_ISLANDS.location())) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //force include biomes
|
||||
// boolean didForceAdd = false;
|
||||
// for (var entry : pickerMap.entrySet()) {
|
||||
// var includeList = includeMap == null ? null : includeMap.get(entry.getKey());
|
||||
// if (includeList != null && includeList.contains(biomeStr)) {
|
||||
// entry.getValue().addBiome(bclBiome);
|
||||
// didForceAdd = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!didForceAdd) {
|
||||
// if (BCLBiomeRegistry.isEmptyBiome(biomeID)
|
||||
// || bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_IGNORE)) {
|
||||
// //we should not add this biome anywhere, so just ignore it
|
||||
// } else {
|
||||
// didForceAdd = false;
|
||||
// for (BiomeDecider decider : deciders) {
|
||||
// if (decider.addToPicker(bclBiome)) {
|
||||
// didForceAdd = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!didForceAdd) {
|
||||
// if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_CENTER)
|
||||
// || TheEndBiomesHelper.canGenerateAsMainIslandBiome(key)) {
|
||||
// endCenterBiomePicker.addBiome(bclBiome);
|
||||
// } else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_LAND)
|
||||
// || TheEndBiomesHelper.canGenerateAsHighlandsBiome(key)) {
|
||||
// if (!config.withVoidBiomes) endVoidBiomePicker.addBiome(bclBiome);
|
||||
// endLandBiomePicker.addBiome(bclBiome);
|
||||
// } else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_BARRENS)
|
||||
// || TheEndBiomesHelper.canGenerateAsEndBarrens(key)) {
|
||||
// endBarrensBiomePicker.addBiome(bclBiome);
|
||||
// } else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_VOID)
|
||||
// || TheEndBiomesHelper.canGenerateAsSmallIslandsBiome(key)) {
|
||||
// endVoidBiomePicker.addBiome(bclBiome);
|
||||
// } else {
|
||||
// BCLib.LOGGER.info("Found End Biome " + biomeStr + " that was not registers with fabric or bclib. Assuming end-land Biome...");
|
||||
// endLandBiomePicker.addBiome(bclBiome);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// endLandBiomePicker.rebuild();
|
||||
// endVoidBiomePicker.rebuild();
|
||||
// endBarrensBiomePicker.rebuild();
|
||||
// endCenterBiomePicker.rebuild();
|
||||
//
|
||||
// for (BiomeDecider decider : deciders) {
|
||||
// decider.rebuild();
|
||||
// }
|
||||
//
|
||||
// if (endVoidBiomePicker.isEmpty()) {
|
||||
// BCLib.LOGGER.info("No Void Biomes found. Disabling by using barrens");
|
||||
// endVoidBiomePicker = endBarrensBiomePicker;
|
||||
// }
|
||||
// if (endBarrensBiomePicker.isEmpty()) {
|
||||
// BCLib.LOGGER.info("No Barrens Biomes found. Disabling by using land Biomes");
|
||||
// endBarrensBiomePicker = endLandBiomePicker;
|
||||
// endVoidBiomePicker = endLandBiomePicker;
|
||||
// }
|
||||
// if (endCenterBiomePicker.isEmpty()) {
|
||||
// BCLib.LOGGER.warning("No Center Island Biomes found. Forcing use of vanilla center.");
|
||||
// endCenterBiomePicker.addBiome(BiomeAPI.THE_END);
|
||||
// endCenterBiomePicker.rebuild();
|
||||
// if (endCenterBiomePicker.isEmpty()) {
|
||||
// BCLib.LOGGER.error("Unable to force vanilla central Island. Falling back to land Biomes...");
|
||||
// endCenterBiomePicker = endLandBiomePicker;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
protected BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes) {
|
||||
datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry, this.bclBiomeRegistry));
|
||||
datapackBiomes.addAll(possibleBiomes().stream()
|
||||
.filter(h -> !h.unwrapKey()
|
||||
.orElseThrow()
|
||||
.location()
|
||||
.getNamespace()
|
||||
.equals("minecraft"))
|
||||
.toList());
|
||||
|
||||
return new BCLibEndBiomeSource(
|
||||
this.biomeRegistry,
|
||||
this.bclBiomeRegistry,
|
||||
datapackBiomes.stream()
|
||||
.filter(b -> b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
.toList(),
|
||||
this.currentSeed,
|
||||
this.config,
|
||||
true
|
||||
);
|
||||
// datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry, this.bclBiomeRegistry));
|
||||
// datapackBiomes.addAll(possibleBiomes().stream()
|
||||
// .filter(h -> !h.unwrapKey()
|
||||
// .orElseThrow()
|
||||
// .location()
|
||||
// .getNamespace()
|
||||
// .equals("minecraft"))
|
||||
// .toList());
|
||||
//
|
||||
// return new BCLibEndBiomeSource(
|
||||
// this.biomeRegistry,
|
||||
// this.bclBiomeRegistry,
|
||||
// datapackBiomes.stream()
|
||||
// .filter(b -> b.unwrapKey()
|
||||
// .orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
// .toList(),
|
||||
// this.currentSeed,
|
||||
// this.config,
|
||||
// true
|
||||
// );
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
bclBiomeRegistry,
|
||||
Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.END),
|
||||
BCLibEndBiomeSource::isValidNonVanillaEndBiome
|
||||
);
|
||||
}
|
||||
// private static List<Holder<Biome>> getNonVanillaBiomes(
|
||||
// HolderGetter<Biome> biomeRegistry,
|
||||
// HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
// ) {
|
||||
// return getBiomes(
|
||||
// biomeRegistry,
|
||||
// bclBiomeRegistry,
|
||||
// Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
// Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.END),
|
||||
// BCLibEndBiomeSource::isValidNonVanillaEndBiome
|
||||
// );
|
||||
// }
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
bclBiomeRegistry,
|
||||
Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.END),
|
||||
BCLibEndBiomeSource::isValidEndBiome
|
||||
);
|
||||
}
|
||||
// private static List<Holder<Biome>> getBiomes(
|
||||
// HolderGetter<Biome> biomeRegistry,
|
||||
// HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
// ) {
|
||||
// return getBiomes(
|
||||
// biomeRegistry,
|
||||
// bclBiomeRegistry,
|
||||
// Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
// Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.END),
|
||||
// BCLibEndBiomeSource::isValidEndBiome
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
private static boolean isValidEndBiome(Holder<Biome> biome, ResourceLocation location) {
|
||||
|
@ -373,6 +457,8 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
|
||||
@Override
|
||||
public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.@NotNull Sampler sampler) {
|
||||
if (!wasBound()) reloadBiomes(false);
|
||||
|
||||
if (mapLand == null || mapVoid == null || mapCenter == null || mapBarrens == null)
|
||||
return this.possibleBiomes().stream().findFirst().orElseThrow();
|
||||
|
||||
|
@ -444,9 +530,14 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toShortString() {
|
||||
return "BCLib - The End BiomeSource (" + Integer.toHexString(hashCode()) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "\nBCLib - The End BiomeSource (" + Integer.toHexString(hashCode()) + ")" +
|
||||
return "\n" + toShortString() +
|
||||
"\n biomes = " + possibleBiomes().size() +
|
||||
"\n namespaces = " + getNamespaces() +
|
||||
"\n seed = " + currentSeed +
|
||||
|
@ -463,12 +554,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
@Override
|
||||
public void setTogetherConfig(BCLEndBiomeSourceConfig newConfig) {
|
||||
this.config = newConfig;
|
||||
this.initMap(currentSeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadBiomes() {
|
||||
rebuildBiomePickers();
|
||||
rebuildBiomes(true);
|
||||
this.initMap(currentSeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,9 @@ import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
|||
import org.betterx.bclib.api.v2.generator.config.MapBuilderFunction;
|
||||
import org.betterx.bclib.api.v2.generator.map.MapStack;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
@ -20,8 +15,7 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
@ -31,14 +25,13 @@ import net.minecraft.world.level.biome.Climate;
|
|||
import net.fabricmc.fabric.api.biome.v1.NetherBiomes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibNetherBiomeSource, BCLNetherBiomeSourceConfig>, ReloadableBiomeSource {
|
||||
public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibNetherBiomeSource, BCLNetherBiomeSourceConfig> {
|
||||
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder
|
||||
.create(instance -> instance
|
||||
.group(
|
||||
RegistryOps.retrieveGetter(Registries.BIOME),
|
||||
RegistryOps.retrieveGetter(BCLBiomeRegistry.BCL_BIOMES_REGISTRY),
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
|
@ -59,118 +52,123 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
private BCLNetherBiomeSourceConfig config;
|
||||
|
||||
public BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
BCLNetherBiomeSourceConfig config
|
||||
) {
|
||||
this(biomeRegistry, bclBiomeRegistry, 0, config, false);
|
||||
this(0, config, false);
|
||||
}
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config
|
||||
) {
|
||||
this(biomeRegistry, bclBiomeRegistry, seed, config, true);
|
||||
this(seed, config, true);
|
||||
}
|
||||
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
this(biomeRegistry, bclBiomeRegistry, getBiomes(biomeRegistry, bclBiomeRegistry), seed, config, initMaps);
|
||||
}
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
super(biomeRegistry, bclBiomeRegistry, list, seed);
|
||||
super(seed);
|
||||
this.config = config;
|
||||
rebuildBiomePicker();
|
||||
rebuildBiomes(false);
|
||||
if (initMaps) {
|
||||
initMap(seed);
|
||||
}
|
||||
}
|
||||
|
||||
private void rebuildBiomePicker() {
|
||||
if (WorldBootstrap.getLastRegistryAccess() == null) {
|
||||
biomePicker = new BiomePicker(null);
|
||||
return;
|
||||
}
|
||||
biomePicker = new BiomePicker(WorldBootstrap.getLastRegistryAccess().lookupOrThrow(Registries.BIOME));
|
||||
Registry<BCLBiome> bclBiomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
this.possibleBiomes().forEach(biome -> {
|
||||
ResourceLocation biomeID = biome.unwrapKey().orElseThrow().location();
|
||||
if (!biome.isBound()) {
|
||||
BCLib.LOGGER.warning("Biome " + biomeID.toString() + " is requested but not yet bound.");
|
||||
return;
|
||||
@Override
|
||||
protected BiomeAPI.BiomeType defaultBiomeType() {
|
||||
return BiomeAPI.BiomeType.NETHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<BiomeAPI.BiomeType, BiomePicker> createFreshPickerMap() {
|
||||
this.biomePicker = new BiomePicker();
|
||||
return Map.of(defaultBiomeType(), this.biomePicker);
|
||||
}
|
||||
|
||||
if (!bclBiomeRegistry.containsKey(biomeID)) {
|
||||
BCLBiome bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.NETHER);
|
||||
InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
biomePicker.addBiome(bclBiome);
|
||||
} else {
|
||||
BCLBiome bclBiome = bclBiomeRegistry.get(biomeID);
|
||||
@Override
|
||||
protected BiomeAPI.BiomeType typeForUnknownBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType defaultType) {
|
||||
//
|
||||
if (NetherBiomes.canGenerateInNether(biomeKey)) {
|
||||
return BiomeAPI.BiomeType.NETHER;
|
||||
}
|
||||
|
||||
if (!BCLBiomeRegistry.isEmptyBiome(bclBiome)) {
|
||||
if (bclBiome.getParentBiome() == null) {
|
||||
biomePicker.addBiome(bclBiome);
|
||||
return super.typeForUnknownBiome(biomeKey, defaultType);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
biomePicker.rebuild();
|
||||
}
|
||||
// private void rebuildBiomePicker() {
|
||||
// if (WorldBootstrap.getLastRegistryAccess() == null) {
|
||||
// biomePicker = new BiomePicker(null);
|
||||
// return;
|
||||
// }
|
||||
// biomePicker = new BiomePicker(WorldBootstrap.getLastRegistryAccess().lookupOrThrow(Registries.BIOME));
|
||||
// Registry<BCLBiome> bclBiomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
// .registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
// this.possibleBiomes().forEach(biome -> {
|
||||
// ResourceLocation biomeID = biome.unwrapKey().orElseThrow().location();
|
||||
// if (!biome.isBound()) {
|
||||
// BCLib.LOGGER.warning("Biome " + biomeID.toString() + " is requested but not yet bound.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (!bclBiomeRegistry.containsKey(biomeID)) {
|
||||
// BCLBiome bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.NETHER);
|
||||
// InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
// biomePicker.addBiome(bclBiome);
|
||||
// } else {
|
||||
// BCLBiome bclBiome = bclBiomeRegistry.get(biomeID);
|
||||
//
|
||||
// if (!BCLBiomeRegistry.isEmptyBiome(bclBiome)) {
|
||||
// if (bclBiome.getParentBiome() == null) {
|
||||
// biomePicker.addBiome(bclBiome);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// biomePicker.rebuild();
|
||||
// }
|
||||
|
||||
protected BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes) {
|
||||
datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry, this.bclBiomeRegistry));
|
||||
datapackBiomes.addAll(possibleBiomes().stream()
|
||||
.filter(h -> !h.unwrapKey()
|
||||
.orElseThrow()
|
||||
.location()
|
||||
.getNamespace()
|
||||
.equals("minecraft"))
|
||||
.toList());
|
||||
return new BCLibNetherBiomeSource(
|
||||
this.biomeRegistry,
|
||||
this.bclBiomeRegistry,
|
||||
datapackBiomes.stream()
|
||||
.filter(b -> b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
.toList(),
|
||||
this.currentSeed,
|
||||
config,
|
||||
true
|
||||
);
|
||||
// datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry, this.bclBiomeRegistry));
|
||||
// datapackBiomes.addAll(possibleBiomes().stream()
|
||||
// .filter(h -> !h.unwrapKey()
|
||||
// .orElseThrow()
|
||||
// .location()
|
||||
// .getNamespace()
|
||||
// .equals("minecraft"))
|
||||
// .toList());
|
||||
// return new BCLibNetherBiomeSource(
|
||||
// datapackBiomes.stream()
|
||||
// .filter(b -> b.unwrapKey()
|
||||
// .orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
// .toList(),
|
||||
// this.currentSeed,
|
||||
// config,
|
||||
// true
|
||||
// );
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
bclBiomeRegistry,
|
||||
exclude,
|
||||
include,
|
||||
BCLibNetherBiomeSource::isValidNonVanillaNetherBiome
|
||||
);
|
||||
// List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
// List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
//
|
||||
// return getBiomes(
|
||||
// biomeRegistry,
|
||||
// bclBiomeRegistry,
|
||||
// exclude,
|
||||
// include,
|
||||
// BCLibNetherBiomeSource::isValidNonVanillaNetherBiome
|
||||
// );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,10 +176,11 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
return getBiomes(biomeRegistry, bclBiomeRegistry, exclude, include, BCLibNetherBiomeSource::isValidNetherBiome);
|
||||
// List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
// List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
//
|
||||
// return getBiomes(biomeRegistry, bclBiomeRegistry, exclude, include, BCLibNetherBiomeSource::isValidNetherBiome);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,6 +209,8 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
|
||||
@Override
|
||||
public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.Sampler var4) {
|
||||
if (!wasBound()) reloadBiomes(false);
|
||||
|
||||
if (biomeMap == null)
|
||||
return this.possibleBiomes().stream().findFirst().get();
|
||||
|
||||
|
@ -251,9 +252,14 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
initMap(currentSeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toShortString() {
|
||||
return "BCLib - Nether BiomeSource (" + Integer.toHexString(hashCode()) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "\nBCLib - Nether BiomeSource (" + Integer.toHexString(hashCode()) + ")" +
|
||||
return "\n" + toShortString() +
|
||||
"\n biomes = " + possibleBiomes().size() +
|
||||
"\n namespaces = " + getNamespaces() +
|
||||
"\n seed = " + currentSeed +
|
||||
|
@ -271,10 +277,4 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
this.config = newConfig;
|
||||
initMap(currentSeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadBiomes() {
|
||||
rebuildBiomePicker();
|
||||
initMap(currentSeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.util.WeighTree;
|
||||
import org.betterx.bclib.util.WeightedList;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
@ -27,6 +29,16 @@ public class BiomePicker {
|
|||
public final ActualBiome fallbackBiome;
|
||||
private WeighTree<ActualBiome> tree;
|
||||
|
||||
BiomePicker() {
|
||||
this(WorldBootstrap.getLastRegistryAccess() == null
|
||||
? null
|
||||
: WorldBootstrap.getLastRegistryAccess().registry(Registries.BIOME).orElse(null));
|
||||
}
|
||||
|
||||
public BiomePicker(Registry<Biome> biomeRegistry) {
|
||||
this(biomeRegistry != null ? biomeRegistry.asLookup() : null, null);
|
||||
}
|
||||
|
||||
public BiomePicker(HolderGetter<Biome> biomeRegistry) {
|
||||
this(biomeRegistry, null);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class LevelGenUtil {
|
|||
|
||||
@NotNull
|
||||
public static LevelStem getBCLNetherLevelStem(WorldGenUtil.Context context, BCLNetherBiomeSourceConfig config) {
|
||||
BCLibNetherBiomeSource netherSource = new BCLibNetherBiomeSource(context.biomes, context.bclBiomes, config);
|
||||
BCLibNetherBiomeSource netherSource = new BCLibNetherBiomeSource(config);
|
||||
|
||||
return new LevelStem(
|
||||
context.dimension,
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.worlds.together.WorldsTogether;
|
|||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
|
@ -12,6 +13,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
|||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
@ -29,7 +31,10 @@ public class BCLBiomeRegistry {
|
|||
BCL_BIOME_CODEC_REGISTRY,
|
||||
BCLBiomeRegistry::bootstrapCodecs
|
||||
);
|
||||
public static MappedRegistry<BCLBiome> BUILTIN_BCL_BIOMES = null;
|
||||
public static Registry<BCLBiome> BUILTIN_BCL_BIOMES = new MappedRegistry<>(
|
||||
BCL_BIOMES_REGISTRY,
|
||||
Lifecycle.stable()
|
||||
);
|
||||
|
||||
/**
|
||||
* Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs.
|
||||
|
@ -37,6 +42,13 @@ public class BCLBiomeRegistry {
|
|||
**/
|
||||
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location());
|
||||
|
||||
public static final BCLBiome THE_END = new BCLBiome(Biomes.THE_END.location(), InternalBiomeAPI.OTHER_END_CENTER);
|
||||
// InternalBiomeAPI.wrapNativeBiome(
|
||||
// Biomes.THE_END,
|
||||
// 0.5F,
|
||||
// InternalBiomeAPI.OTHER_END_CENTER
|
||||
// );
|
||||
|
||||
public static boolean isEmptyBiome(ResourceLocation l) {
|
||||
return l == null || Biomes.THE_VOID.location().equals(l);
|
||||
}
|
||||
|
@ -65,22 +77,42 @@ public class BCLBiomeRegistry {
|
|||
/**
|
||||
* Register new Biome Data
|
||||
*
|
||||
* @param access The {@link RegistryAccess} to use. If null, we will use the
|
||||
* built inregistry ({@link BCLBiomeRegistry#BUILTIN_BCL_BIOMES})
|
||||
* @param biome The Biome Data to register
|
||||
* @return The resource-key for the registry
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static ResourceKey<BCLBiome> register(RegistryAccess access, BCLBiome biome) {
|
||||
if (access != null && BUILTIN_BCL_BIOMES == null) return biome.getBCLBiomeKey();
|
||||
public static ResourceKey<BCLBiome> registerForDatagen(BCLBiome biome) {
|
||||
if (BUILTIN_BCL_BIOMES == null) return biome.getBCLBiomeKey();
|
||||
|
||||
Registry.register(
|
||||
access == null ? BUILTIN_BCL_BIOMES : access.registryOrThrow(BCL_BIOMES_REGISTRY),
|
||||
BUILTIN_BCL_BIOMES,
|
||||
biome.getBCLBiomeKey(),
|
||||
biome
|
||||
);
|
||||
|
||||
return biome.getBCLBiomeKey();
|
||||
}
|
||||
|
||||
public static void register(BCLBiome biome) {
|
||||
registerForDatagen(biome);
|
||||
}
|
||||
|
||||
public static boolean hasBiome(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) {
|
||||
if (bclBiomes != null && bclBiomes.containsKey(key.location())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return BUILTIN_BCL_BIOMES.containsKey(key.location());
|
||||
}
|
||||
|
||||
public static BCLBiome getBiome(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) {
|
||||
if (bclBiomes != null && bclBiomes.containsKey(key.location())) {
|
||||
return bclBiomes.get(key.location());
|
||||
}
|
||||
|
||||
return BUILTIN_BCL_BIOMES.get(key.location());
|
||||
}
|
||||
|
||||
private static <T> ResourceKey<Registry<T>> createRegistryKey(ResourceLocation location) {
|
||||
return ResourceKey.createRegistryKey(location);
|
||||
}
|
||||
|
@ -90,42 +122,6 @@ public class BCLBiomeRegistry {
|
|||
return Registry.register(registry, BCLib.makeID("biome"), BCLBiome.KEY_CODEC.codec());
|
||||
}
|
||||
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static BCLBiome bootstrap(Registry<BCLBiome> registry) {
|
||||
Registry.register(registry, BiomeAPI.SMALL_END_ISLANDS.getBCLBiomeKey(), BiomeAPI.SMALL_END_ISLANDS);
|
||||
Registry.register(registry, BiomeAPI.END_BARRENS.getBCLBiomeKey(), BiomeAPI.END_BARRENS);
|
||||
Registry.register(registry, BiomeAPI.END_HIGHLANDS.getBCLBiomeKey(), BiomeAPI.END_HIGHLANDS);
|
||||
Registry.register(registry, BiomeAPI.END_MIDLANDS.getBCLBiomeKey(), BiomeAPI.END_MIDLANDS);
|
||||
Registry.register(registry, BiomeAPI.THE_END.getBCLBiomeKey(), BiomeAPI.THE_END);
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.BASALT_DELTAS_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.BASALT_DELTAS_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.SOUL_SAND_VALLEY_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.WARPED_FOREST_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.WARPED_FOREST_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.CRIMSON_FOREST_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.CRIMSON_FOREST_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
registry,
|
||||
BiomeAPI.NETHER_WASTES_BIOME.getBCLBiomeKey(),
|
||||
BiomeAPI.NETHER_WASTES_BIOME
|
||||
);
|
||||
return Registry.register(registry, EMPTY_BIOME.getBCLBiomeKey(), EMPTY_BIOME);
|
||||
}
|
||||
|
||||
public static BCLBiome get(ResourceLocation loc) {
|
||||
return get(WorldBootstrap.getLastRegistryAccess(), loc);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
@ -228,60 +227,6 @@ public class BiomeAPI {
|
|||
}
|
||||
}
|
||||
|
||||
public static final BCLBiome NETHER_WASTES_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.NETHER_WASTES,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
public static final BCLBiome CRIMSON_FOREST_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.CRIMSON_FOREST,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
public static final BCLBiome WARPED_FOREST_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.WARPED_FOREST,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.SOUL_SAND_VALLEY,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
public static final BCLBiome BASALT_DELTAS_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.BASALT_DELTAS,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
|
||||
|
||||
public static final BCLBiome THE_END = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.THE_END,
|
||||
0.5F,
|
||||
InternalBiomeAPI.OTHER_END_CENTER
|
||||
);
|
||||
|
||||
public static final BCLBiome END_MIDLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_MIDLANDS,
|
||||
0.5F,
|
||||
InternalBiomeAPI.OTHER_END_LAND
|
||||
);
|
||||
|
||||
public static final BCLBiome END_HIGHLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_HIGHLANDS,
|
||||
END_MIDLANDS,
|
||||
8,
|
||||
0.5F,
|
||||
InternalBiomeAPI.OTHER_END_LAND
|
||||
);
|
||||
|
||||
|
||||
public static final BCLBiome END_BARRENS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_BARRENS,
|
||||
InternalBiomeAPI.OTHER_END_BARRENS
|
||||
);
|
||||
|
||||
public static final BCLBiome SMALL_END_ISLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.SMALL_END_ISLANDS,
|
||||
InternalBiomeAPI.OTHER_END_VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||
*
|
||||
|
@ -296,7 +241,7 @@ public class BiomeAPI {
|
|||
&& registryOrNull.get(bclbiome.getBiomeKey()).map(v -> v.isBound()).orElse(false) == false) {
|
||||
bootstrapContext.register(bclbiome.getBiomeKey(), bclbiome._getBiomeToRegister());
|
||||
|
||||
BCLBiomeRegistry.register(null, bclbiome);
|
||||
BCLBiomeRegistry.registerForDatagen(bclbiome);
|
||||
}
|
||||
|
||||
return finishBiomeRegistration(bclbiome);
|
||||
|
|
|
@ -290,15 +290,6 @@ public class InternalBiomeAPI {
|
|||
return BIOME_ADDITIONS.computeIfAbsent(registry, reg -> new AtomicInteger(0)).get();
|
||||
}
|
||||
|
||||
public static void registerBCLBiomeData(BCLBiome biome) {
|
||||
try {
|
||||
BCLBiomeRegistry.register(registryAccess, biome);
|
||||
} catch (IllegalStateException e) {
|
||||
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||
BCLib.LOGGER.info("Not managing Biome " + biome.getID());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||
*
|
||||
|
|
|
@ -34,10 +34,7 @@ public abstract class BuiltinRegistriesMixin {
|
|||
if (BCLib.isDatagen()) {
|
||||
// BCLBiomeRegistry.BUILTIN_BCL_BIOMES = internalRegister(
|
||||
// BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
|
||||
// new MappedRegistry<>(
|
||||
// BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
|
||||
// Lifecycle.stable()
|
||||
// ),
|
||||
// BCLBiomeRegistry.BUILTIN_BCL_BIOMES,
|
||||
// BCLBiomeRegistry::bootstrap,
|
||||
// Lifecycle.stable()
|
||||
// );
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.betterx.datagen.bclib.tests.TestPlacedFeatures;
|
|||
import org.betterx.datagen.bclib.tests.TestWorldgenProvider;
|
||||
import org.betterx.datagen.bclib.worldgen.BCLibRegistriesDataProvider;
|
||||
import org.betterx.datagen.bclib.worldgen.NoiseTypesDataProvider;
|
||||
import org.betterx.datagen.bclib.worldgen.VanillaBCLBiomesDataProvider;
|
||||
import org.betterx.datagen.bclib.worldgen.WorldgenRegistriesDataProvider;
|
||||
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
|
@ -22,6 +23,8 @@ public class BCLibDatagen implements DataGeneratorEntrypoint {
|
|||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
|
||||
BCLib.LOGGER.info("Bootstrap onInitializeDataGenerator");
|
||||
VanillaBCLBiomesDataProvider.create();
|
||||
|
||||
final FabricDataGenerator.Pack pack = dataGenerator.createPack();
|
||||
|
||||
if (ADD_TESTS) {
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package org.betterx.datagen.bclib.worldgen;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
|
||||
public class VanillaBCLBiomesDataProvider {
|
||||
private static boolean didBootstrap = false;
|
||||
|
||||
public static void create() {
|
||||
BCLBiomeRegistry.BUILTIN_BCL_BIOMES = BuiltInRegistries.registerSimple(
|
||||
BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
|
||||
VanillaBCLBiomesDataProvider::bootstrap
|
||||
);
|
||||
|
||||
bootstrap(BCLBiomeRegistry.BUILTIN_BCL_BIOMES);
|
||||
}
|
||||
|
||||
public static BCLBiome bootstrap(Registry<BCLBiome> reg) {
|
||||
if (didBootstrap) return BCLBiomeRegistry.EMPTY_BIOME;
|
||||
didBootstrap = true;
|
||||
|
||||
final BCLBiome NETHER_WASTES_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.NETHER_WASTES,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome CRIMSON_FOREST_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.CRIMSON_FOREST,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome WARPED_FOREST_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.WARPED_FOREST,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome SOUL_SAND_VALLEY_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.SOUL_SAND_VALLEY,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome BASALT_DELTAS_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.BASALT_DELTAS,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
|
||||
|
||||
final BCLBiome END_MIDLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_MIDLANDS,
|
||||
0.5F,
|
||||
InternalBiomeAPI.OTHER_END_LAND
|
||||
);
|
||||
|
||||
final BCLBiome END_HIGHLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_HIGHLANDS,
|
||||
END_MIDLANDS,
|
||||
8,
|
||||
0.5F,
|
||||
InternalBiomeAPI.OTHER_END_LAND
|
||||
);
|
||||
|
||||
|
||||
final BCLBiome END_BARRENS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_BARRENS,
|
||||
InternalBiomeAPI.OTHER_END_BARRENS
|
||||
);
|
||||
|
||||
final BCLBiome SMALL_END_ISLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.SMALL_END_ISLANDS,
|
||||
InternalBiomeAPI.OTHER_END_VOID
|
||||
);
|
||||
Registry.register(reg, SMALL_END_ISLANDS.getBCLBiomeKey(), SMALL_END_ISLANDS);
|
||||
Registry.register(reg, END_BARRENS.getBCLBiomeKey(), END_BARRENS);
|
||||
Registry.register(reg, END_HIGHLANDS.getBCLBiomeKey(), END_HIGHLANDS);
|
||||
Registry.register(reg, END_MIDLANDS.getBCLBiomeKey(), END_MIDLANDS);
|
||||
Registry.register(reg, BCLBiomeRegistry.THE_END.getBCLBiomeKey(), BCLBiomeRegistry.THE_END);
|
||||
Registry.register(
|
||||
reg,
|
||||
BASALT_DELTAS_BIOME.getBCLBiomeKey(),
|
||||
BASALT_DELTAS_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(),
|
||||
SOUL_SAND_VALLEY_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
WARPED_FOREST_BIOME.getBCLBiomeKey(),
|
||||
WARPED_FOREST_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
CRIMSON_FOREST_BIOME.getBCLBiomeKey(),
|
||||
CRIMSON_FOREST_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
NETHER_WASTES_BIOME.getBCLBiomeKey(),
|
||||
NETHER_WASTES_BIOME
|
||||
);
|
||||
return Registry.register(reg, BCLBiomeRegistry.EMPTY_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.EMPTY_BIOME);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import net.minecraft.core.HolderGetter;
|
|||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface BiomeSourceFromRegistry<T extends BiomeSource> {
|
||||
HolderGetter<Biome> getBiomeRegistry();
|
||||
boolean didBiomeRegistryChange();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue