[Change] Removed deprecated methods from BiomeSources
This commit is contained in:
parent
f337595222
commit
62d54eb425
3 changed files with 1 additions and 341 deletions
|
@ -21,8 +21,6 @@ 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.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -95,23 +93,12 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
protected abstract void onInitMap(long newSeed);
|
||||
protected abstract void onHeightChange(int newHeight);
|
||||
|
||||
public BCLBiomeSource createCopyForDatapack(Set<Holder<Biome>> datapackBiomes) {
|
||||
Set<Holder<Biome>> mutableSet = Sets.newHashSet();
|
||||
mutableSet.addAll(datapackBiomes);
|
||||
return cloneForDatapack(mutableSet);
|
||||
}
|
||||
|
||||
protected abstract BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes);
|
||||
|
||||
@NotNull
|
||||
protected String getNamespaces() {
|
||||
return BiomeSourceHelper.getNamespaces(possibleBiomes());
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -16,8 +16,6 @@ import net.minecraft.core.Registry;
|
|||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
|
@ -27,7 +25,6 @@ import net.minecraft.world.level.levelgen.DensityFunction;
|
|||
import java.awt.*;
|
||||
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> {
|
||||
|
@ -183,220 +180,6 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
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
|
||||
// );
|
||||
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>> 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) {
|
||||
if (BiomeAPI.wasRegisteredAs(location, BiomeAPI.BiomeType.END_IGNORE)) return false;
|
||||
|
||||
return biome.is(BiomeTags.IS_END) ||
|
||||
BiomeAPI.wasRegisteredAsEndBiome(location) ||
|
||||
TheEndBiomesHelper.canGenerateInEnd(biome.unwrapKey().orElse(null));
|
||||
}
|
||||
|
||||
private static boolean isValidNonVanillaEndBiome(Holder<Biome> biome, ResourceLocation location) {
|
||||
if (BiomeAPI.wasRegisteredAs(location, BiomeAPI.BiomeType.END_IGNORE) || biome.unwrapKey()
|
||||
.orElseThrow()
|
||||
.location()
|
||||
.getNamespace()
|
||||
.equals("minecraft"))
|
||||
return false;
|
||||
|
||||
return biome.is(BiomeTags.IS_END) ||
|
||||
BiomeAPI.wasRegisteredAsEndBiome(location) ||
|
||||
TheEndBiomesHelper.canGenerateInEnd(biome.unwrapKey().orElse(null));
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.betterx.bclib.BCLib;
|
|||
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.BiomeAPI;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
|
@ -12,21 +11,16 @@ import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
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> {
|
||||
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder
|
||||
|
@ -99,114 +93,10 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
return super.typeForUnknownBiome(biomeKey, defaultType);
|
||||
}
|
||||
|
||||
// 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(
|
||||
// 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
|
||||
// );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isValidNetherBiome(Holder<Biome> biome, ResourceLocation location) {
|
||||
return NetherBiomes.canGenerateInNether(biome.unwrapKey().get()) ||
|
||||
biome.is(BiomeTags.IS_NETHER) ||
|
||||
BiomeAPI.wasRegisteredAsNetherBiome(location);
|
||||
}
|
||||
|
||||
private static boolean isValidNonVanillaNetherBiome(Holder<Biome> biome, ResourceLocation location) {
|
||||
if (BiomeAPI.wasRegisteredAs(location, BiomeAPI.BiomeType.END_IGNORE) || biome.unwrapKey()
|
||||
.orElseThrow()
|
||||
.location()
|
||||
.getNamespace()
|
||||
.equals("minecraft"))
|
||||
return false;
|
||||
|
||||
return NetherBiomes.canGenerateInNether(biome.unwrapKey().get()) ||
|
||||
BiomeAPI.wasRegisteredAsNetherBiome(location);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, BCLib.makeID("nether_biome_source"), CODEC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.Sampler var4) {
|
||||
if (!wasBound()) reloadBiomes(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue