Cave related changes
This commit is contained in:
parent
a57845f96b
commit
558bd7d326
3 changed files with 46 additions and 38 deletions
|
@ -81,7 +81,31 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class BiomeAPI {
|
public class BiomeAPI {
|
||||||
enum Dimension {OVERWORLD, NETHER, END_LAND, END_VOID, UNDEFINED};
|
public static class Dimension {
|
||||||
|
public static final Dimension NONE = new Dimension();
|
||||||
|
public static final Dimension OVERWORLD = new Dimension();
|
||||||
|
public static final Dimension NETHER = new Dimension();
|
||||||
|
public static final Dimension END = new Dimension();
|
||||||
|
public static final Dimension END_LAND = new Dimension(END);
|
||||||
|
public static final Dimension END_VOID = new Dimension(END);
|
||||||
|
|
||||||
|
private static final Map<ResourceLocation, Dimension> DIMENSION_MAP = Maps.newHashMap();
|
||||||
|
public final Dimension parentOrNull;
|
||||||
|
|
||||||
|
public Dimension() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension(Dimension parentOrNull) {
|
||||||
|
this.parentOrNull = parentOrNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is(Dimension d){
|
||||||
|
if (d==this) return true;
|
||||||
|
if (parentOrNull!=null) return parentOrNull.is(d);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs.
|
* Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs.
|
||||||
* Have {@code Biomes.THE_VOID} as the reference biome.
|
* Have {@code Biomes.THE_VOID} as the reference biome.
|
||||||
|
@ -89,7 +113,6 @@ public class BiomeAPI {
|
||||||
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location());
|
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location());
|
||||||
|
|
||||||
private static final Map<ResourceLocation, BCLBiome> ID_MAP = Maps.newHashMap();
|
private static final Map<ResourceLocation, BCLBiome> ID_MAP = Maps.newHashMap();
|
||||||
private static final Map<ResourceLocation, Dimension> DIMENSION_MAP = Maps.newHashMap();
|
|
||||||
private static final Map<Biome, BCLBiome> CLIENT = Maps.newHashMap();
|
private static final Map<Biome, BCLBiome> CLIENT = Maps.newHashMap();
|
||||||
public static Registry<Biome> biomeRegistry;
|
public static Registry<Biome> biomeRegistry;
|
||||||
|
|
||||||
|
@ -170,13 +193,12 @@ public class BiomeAPI {
|
||||||
Registry.register(BuiltinRegistries.BIOME, loc, biome);
|
Registry.register(BuiltinRegistries.BIOME, loc, biome);
|
||||||
}
|
}
|
||||||
ID_MAP.put(bclbiome.getID(), bclbiome);
|
ID_MAP.put(bclbiome.getID(), bclbiome);
|
||||||
DIMENSION_MAP.put(bclbiome.getID(), dim);
|
Dimension.DIMENSION_MAP.put(bclbiome.getID(), dim);
|
||||||
|
|
||||||
if (dim==Dimension.NETHER) {
|
|
||||||
|
|
||||||
|
if (dim.is(Dimension.NETHER)) {
|
||||||
TagAPI.addBiomeTag(BiomeTags.IS_NETHER, bclbiome.getBiome());
|
TagAPI.addBiomeTag(BiomeTags.IS_NETHER, bclbiome.getBiome());
|
||||||
TagAPI.addBiomeTag(CommonBiomeTags.IN_NETHER, bclbiome.getBiome());
|
TagAPI.addBiomeTag(CommonBiomeTags.IN_NETHER, bclbiome.getBiome());
|
||||||
} else if (dim==Dimension.END_LAND || dim==Dimension.END_VOID) {
|
} else if (dim.is(Dimension.END)) {
|
||||||
TagAPI.addBiomeTag(BiomeTags.IS_END, bclbiome.getBiome());
|
TagAPI.addBiomeTag(BiomeTags.IS_END, bclbiome.getBiome());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +208,7 @@ public class BiomeAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BCLBiome registerSubBiome(BCLBiome parent, BCLBiome subBiome) {
|
public static BCLBiome registerSubBiome(BCLBiome parent, BCLBiome subBiome) {
|
||||||
final Dimension dim = DIMENSION_MAP.getOrDefault(parent.getID(), Dimension.UNDEFINED);
|
final Dimension dim = Dimension.DIMENSION_MAP.getOrDefault(parent.getID(), Dimension.NONE);
|
||||||
registerBiome(subBiome, dim);
|
registerBiome(subBiome, dim);
|
||||||
parent.addSubBiome(subBiome);
|
parent.addSubBiome(subBiome);
|
||||||
|
|
||||||
|
@ -458,19 +480,24 @@ public class BiomeAPI {
|
||||||
return getFromRegistry(biomeID) == null;
|
return getFromRegistry(biomeID) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean wasRegisteredAs(ResourceLocation biomeID, Dimension dim) {
|
||||||
|
if (!Dimension.DIMENSION_MAP.containsKey(biomeID)) return false;
|
||||||
|
return Dimension.DIMENSION_MAP.get(biomeID).is(dim);
|
||||||
|
}
|
||||||
public static boolean wasRegisteredAsNetherBiome(ResourceLocation biomeID) {
|
public static boolean wasRegisteredAsNetherBiome(ResourceLocation biomeID) {
|
||||||
if (!DIMENSION_MAP.containsKey(biomeID)) return false;
|
return wasRegisteredAs(biomeID, Dimension.NETHER);
|
||||||
return DIMENSION_MAP.get(biomeID)==Dimension.NETHER;
|
}
|
||||||
|
|
||||||
|
public static boolean wasRegisteredAsEndBiome(ResourceLocation biomeID) {
|
||||||
|
return wasRegisteredAs(biomeID, Dimension.END);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean wasRegisteredAsEndLandBiome(ResourceLocation biomeID) {
|
public static boolean wasRegisteredAsEndLandBiome(ResourceLocation biomeID) {
|
||||||
if (!DIMENSION_MAP.containsKey(biomeID)) return false;
|
return wasRegisteredAs(biomeID, Dimension.END_LAND);
|
||||||
return DIMENSION_MAP.get(biomeID)==Dimension.END_LAND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean wasRegisteredAsEndVoidBiome(ResourceLocation biomeID) {
|
public static boolean wasRegisteredAsEndVoidBiome(ResourceLocation biomeID) {
|
||||||
if (!DIMENSION_MAP.containsKey(biomeID)) return false;
|
return wasRegisteredAs(biomeID, Dimension.END_VOID);
|
||||||
return DIMENSION_MAP.get(biomeID)==Dimension.END_VOID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -513,8 +540,8 @@ public class BiomeAPI {
|
||||||
public static void _runTagAdders(){
|
public static void _runTagAdders(){
|
||||||
for (var mod:TAG_ADDERS.entrySet()) {
|
for (var mod:TAG_ADDERS.entrySet()) {
|
||||||
Stream<ResourceLocation> s = null;
|
Stream<ResourceLocation> s = null;
|
||||||
if (mod.getKey()==Level.NETHER) s = DIMENSION_MAP.entrySet().stream().filter(e ->e.getValue() == Dimension.NETHER).map(e -> e.getKey());
|
if (mod.getKey()==Level.NETHER) s = Dimension.DIMENSION_MAP.entrySet().stream().filter(e ->e.getValue().is(Dimension.NETHER)).map(e -> e.getKey());
|
||||||
else if (mod.getKey()==Level.END) s = DIMENSION_MAP.entrySet().stream().filter(e ->e.getValue() == Dimension.END_VOID || e.getValue()==Dimension.END_LAND).map(e -> e.getKey());
|
else if (mod.getKey()==Level.END) s = Dimension.DIMENSION_MAP.entrySet().stream().filter(e ->e.getValue().is(Dimension.END)).map(e -> e.getKey());
|
||||||
if (s!=null) {
|
if (s!=null) {
|
||||||
s.forEach(id -> {
|
s.forEach(id -> {
|
||||||
BCLBiome b = BiomeAPI.getBiome(id);
|
BCLBiome b = BiomeAPI.getBiome(id);
|
||||||
|
@ -565,26 +592,6 @@ public class BiomeAPI {
|
||||||
|
|
||||||
if (chunkGenerator instanceof NoiseGeneratorSettingsProvider gen)
|
if (chunkGenerator instanceof NoiseGeneratorSettingsProvider gen)
|
||||||
noiseGeneratorSettings = gen.bclib_getNoiseGeneratorSettings();
|
noiseGeneratorSettings = gen.bclib_getNoiseGeneratorSettings();
|
||||||
/*final Registry<StructureSet> structureSetRegistry;
|
|
||||||
if (chunkGenerator instanceof ChunkGeneratorAccessor acc) {
|
|
||||||
structureSetRegistry = acc.bclib_getStructureSetsRegistry();
|
|
||||||
} else {
|
|
||||||
structureSetRegistry = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
noiseGeneratorSettings = level
|
|
||||||
.getServer()
|
|
||||||
.getWorldData()
|
|
||||||
.worldGenSettings()
|
|
||||||
.dimensions()
|
|
||||||
.stream()
|
|
||||||
.map(dim->dim.generator())
|
|
||||||
.filter(gen-> structureSetRegistry!=null && (gen instanceof NoiseGeneratorSettingsProvider) && (gen instanceof ChunkGeneratorAccessor) && ((ChunkGeneratorAccessor)gen).bclib_getStructureSetsRegistry()==structureSetRegistry)
|
|
||||||
.map(gen->((NoiseGeneratorSettingsProvider)gen).bclib_getNoiseGeneratorSettings())
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);*/
|
|
||||||
|
|
||||||
|
|
||||||
// Datapacks (like Amplified Nether)will change the GeneratorSettings upon load, so we will
|
// Datapacks (like Amplified Nether)will change the GeneratorSettings upon load, so we will
|
||||||
// only use the default Setting for Nether/End if we were unable to find a settings object
|
// only use the default Setting for Nether/End if we were unable to find a settings object
|
||||||
|
|
|
@ -126,8 +126,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isEndBiome = biome.is(BiomeTags.IS_END) ||
|
final boolean isEndBiome = biome.is(BiomeTags.IS_END) ||
|
||||||
BiomeAPI.wasRegisteredAsEndVoidBiome(key) ||
|
BiomeAPI.wasRegisteredAsEndBiome(key);
|
||||||
BiomeAPI.wasRegisteredAsEndLandBiome(key);
|
|
||||||
if (GeneratorOptions.addEndBiomesByTag() && isEndBiome) {
|
if (GeneratorOptions.addEndBiomesByTag() && isEndBiome) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -194,6 +193,8 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSeed(long seed) {
|
public void setSeed(long seed) {
|
||||||
|
if (seed==currentSeed) return;
|
||||||
|
|
||||||
super.setSeed(seed);
|
super.setSeed(seed);
|
||||||
initMap(seed);
|
initMap(seed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class BiomePicker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List<Entry> biomes = Lists.newArrayList();
|
private final List<Entry> biomes = Lists.newArrayList();
|
||||||
private final Registry<Biome> biomeRegistry;
|
public final Registry<Biome> biomeRegistry;
|
||||||
private WeighTree<Entry> tree;
|
private WeighTree<Entry> tree;
|
||||||
|
|
||||||
public BiomePicker(Registry<Biome> biomeRegistry){
|
public BiomePicker(Registry<Biome> biomeRegistry){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue