More BiomeSource related fixes
This commit is contained in:
parent
2eccb1cb9e
commit
6c015a9a53
6 changed files with 93 additions and 84 deletions
|
@ -191,7 +191,7 @@ public class BCLBiome extends BCLBiomeSettings {
|
|||
* Recursively update biomes to correct world biome registry instances, for internal usage only.
|
||||
* @param biomeRegistry {@link Registry} for {@link Biome}.
|
||||
*/
|
||||
public void updateActualBiomes(Registry<Holder<Biome>> biomeRegistry) {
|
||||
public void updateActualBiomes(Registry<Biome> biomeRegistry) {
|
||||
subbiomes.forEach((sub) -> {
|
||||
if (sub != this) {
|
||||
sub.updateActualBiomes(biomeRegistry);
|
||||
|
@ -201,8 +201,8 @@ public class BCLBiome extends BCLBiomeSettings {
|
|||
edge.updateActualBiomes(biomeRegistry);
|
||||
}
|
||||
|
||||
final ResourceKey<Holder<Biome>> key = ResourceKey.create(biomeRegistry.key(), biomeID);
|
||||
this.actualBiome = biomeRegistry.get(key);
|
||||
final ResourceKey<Biome> key = biomeRegistry.getResourceKey(biomeRegistry.get(biomeID)).orElseThrow();
|
||||
this.actualBiome = biomeRegistry.getOrCreateHolder(key);
|
||||
if (actualBiome==null) {
|
||||
BCLib.LOGGER.error("Unable to find actual Biome for " + biomeID);
|
||||
}
|
||||
|
|
|
@ -9,15 +9,15 @@ import ru.bclib.api.biomes.BiomeAPI;
|
|||
import java.util.List;
|
||||
|
||||
public abstract class BCLBiomeSource extends BiomeSource {
|
||||
protected final Registry<Holder<Biome>> biomeRegistry;
|
||||
protected final Registry<Biome> biomeRegistry;
|
||||
protected final long seed;
|
||||
|
||||
private static List<Holder<Biome>> preInit(Registry<Holder<Biome>> biomeRegistry, List<Holder<Biome>> biomes){
|
||||
private static List<Holder<Biome>> preInit(Registry<Biome> biomeRegistry, List<Holder<Biome>> biomes){
|
||||
biomes.forEach(biome -> BiomeAPI.sortBiomeFeatures(biome));
|
||||
return biomes;
|
||||
}
|
||||
|
||||
protected BCLBiomeSource(Registry<Holder<Biome>> biomeRegistry, long seed, List<Holder<Biome>> list) {
|
||||
protected BCLBiomeSource(Registry<Biome> biomeRegistry, long seed, List<Holder<Biome>> list) {
|
||||
super(preInit(biomeRegistry, list));
|
||||
|
||||
this.seed = seed;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
private BiomeMap mapVoid;
|
||||
private final Point pos;
|
||||
|
||||
public BCLibEndBiomeSource(Registry<Holder<Biome>> biomeRegistry, long seed) {
|
||||
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||
super(biomeRegistry, seed, getBiomes(biomeRegistry));
|
||||
|
||||
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
|
||||
|
@ -53,7 +53,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
|
||||
List<String> includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue();
|
||||
this.possibleBiomes().forEach(biome -> {
|
||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||
ResourceLocation key = biome.unwrapKey().orElseThrow().location();
|
||||
String group = key.getNamespace() + "." + key.getPath();
|
||||
|
||||
if (!BiomeAPI.hasBiome(key)) {
|
||||
|
@ -98,8 +98,8 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
this.mapVoid = new HexBiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER);
|
||||
}
|
||||
|
||||
this.centerBiome = biomeRegistry.get(Biomes.THE_END.location());
|
||||
this.barrens = biomeRegistry.get(Biomes.END_BARRENS.location());
|
||||
this.centerBiome = biomeRegistry.getOrCreateHolder(Biomes.THE_END);
|
||||
this.barrens = biomeRegistry.getOrCreateHolder(Biomes.END_BARRENS);
|
||||
|
||||
WorldgenRandom chunkRandom = new WorldgenRandom(new LegacyRandomSource(seed));
|
||||
chunkRandom.consumeCount(17292);
|
||||
|
@ -109,35 +109,39 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
this.pos = new Point();
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Holder<Biome>> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
List<String> includeLand = Configs.BIOMES_CONFIG.getEntry("force_include", "end_land_biomes", StringArrayEntry.class).getValue();
|
||||
List<String> includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue();
|
||||
|
||||
return biomeRegistry.stream().filter(biome -> {
|
||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||
|
||||
if (includeLand.contains(key.toString()) || includeVoid.contains(key.toString())) {
|
||||
return true;
|
||||
}
|
||||
return biomeRegistry.stream()
|
||||
.filter(biome -> biomeRegistry.getResourceKey(biome).isPresent())
|
||||
.map(biome -> biomeRegistry.getOrCreateHolder(biomeRegistry.getResourceKey(biome).get()))
|
||||
.filter(biome -> {
|
||||
ResourceLocation key = biome.unwrapKey().orElseThrow().location();
|
||||
|
||||
final boolean isEndBiome;
|
||||
if ((Object)biome instanceof BiomeAccessor bacc) {
|
||||
isEndBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.THEEND;
|
||||
if (GeneratorOptions.addEndBiomesByCategory() && isEndBiome) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
isEndBiome = false;
|
||||
}
|
||||
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||
if (bclBiome.getParentBiome() != null) {
|
||||
bclBiome = bclBiome.getParentBiome();
|
||||
}
|
||||
key = bclBiome.getID();
|
||||
}
|
||||
return BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) || BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key) || (isEndBiome && BiomeAPI.isDatapackBiome(key));
|
||||
|
||||
if (includeLand.contains(key.toString()) || includeVoid.contains(key.toString())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final boolean isEndBiome;
|
||||
if ((Object)biome instanceof BiomeAccessor bacc) {
|
||||
isEndBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.THEEND;
|
||||
if (GeneratorOptions.addEndBiomesByCategory() && isEndBiome) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
isEndBiome = false;
|
||||
}
|
||||
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||
if (bclBiome.getParentBiome() != null) {
|
||||
bclBiome = bclBiome.getParentBiome();
|
||||
}
|
||||
key = bclBiome.getID();
|
||||
}
|
||||
return BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) || BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key) || (isEndBiome && BiomeAPI.isDatapackBiome(key));
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
.create(instance -> instance
|
||||
.group(RegistryOps
|
||||
.retrieveRegistry(Registry.BIOME_REGISTRY)
|
||||
.forGetter(source -> null)
|
||||
.forGetter(source -> source.biomeRegistry)
|
||||
,
|
||||
Codec
|
||||
.LONG
|
||||
|
@ -67,7 +67,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
BCLibNetherBiomeSource.worldHeight = worldHeight;
|
||||
}
|
||||
|
||||
public BCLibNetherBiomeSource(Registry<Holder<Biome>> biomeRegistry, long seed) {
|
||||
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||
super(biomeRegistry, seed, getBiomes(biomeRegistry));
|
||||
|
||||
BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
|
||||
|
@ -97,34 +97,37 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
initMap();
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Holder<Biome>> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getEntry("force_include", "nether_biomes", StringArrayEntry.class).getValue();
|
||||
|
||||
return biomeRegistry.stream().filter(biome -> {
|
||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||
|
||||
if (include.contains(key.toString())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GeneratorOptions.addNetherBiomesByCategory() && (biome instanceof BiomeAccessor) && ((BiomeAccessor)(Object)biome).bclib_getBiomeCategory()== BiomeCategory.NETHER) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||
if (bclBiome.getParentBiome() != null) {
|
||||
bclBiome = bclBiome.getParentBiome();
|
||||
}
|
||||
key = bclBiome.getID();
|
||||
}
|
||||
final boolean isNetherBiome;
|
||||
if ((Object)biome instanceof BiomeAccessor bacc) {
|
||||
isNetherBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.NETHER;
|
||||
} else {
|
||||
isNetherBiome = false;
|
||||
}
|
||||
return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) || (isNetherBiome && BiomeAPI.isDatapackBiome(key));
|
||||
|
||||
return biomeRegistry.stream()
|
||||
.filter(biome -> biomeRegistry.getResourceKey(biome).isPresent())
|
||||
.map(biome -> biomeRegistry.getOrCreateHolder(biomeRegistry.getResourceKey(biome).get()))
|
||||
.filter(biome -> {
|
||||
ResourceLocation key = biome.unwrapKey().orElseThrow().location();
|
||||
|
||||
if (include.contains(key.toString())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GeneratorOptions.addNetherBiomesByCategory() && (biome instanceof BiomeAccessor) && ((BiomeAccessor)(Object)biome).bclib_getBiomeCategory()== BiomeCategory.NETHER) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||
if (bclBiome.getParentBiome() != null) {
|
||||
bclBiome = bclBiome.getParentBiome();
|
||||
}
|
||||
key = bclBiome.getID();
|
||||
}
|
||||
final boolean isNetherBiome;
|
||||
if ((Object)biome instanceof BiomeAccessor bacc) {
|
||||
isNetherBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.NETHER;
|
||||
} else {
|
||||
isNetherBiome = false;
|
||||
}
|
||||
return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) || (isNetherBiome && BiomeAPI.isDatapackBiome(key));
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue