Crash fixes
This commit is contained in:
parent
97ad8b44aa
commit
7e36ac4159
5 changed files with 71 additions and 30 deletions
|
@ -41,15 +41,15 @@ public class BiomeAPI {
|
|||
private static final Map<Biome, BCLBiome> CLIENT = Maps.newHashMap();
|
||||
private static Registry<Biome> biomeRegistry;
|
||||
|
||||
public static final BCLBiome NETHER_WASTES_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("nether_wastes")));
|
||||
public static final BCLBiome CRIMSON_FOREST_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("crimson_forest")));
|
||||
public static final BCLBiome WARPED_FOREST_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("warped_forest")));
|
||||
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("soul_sand_valley")));
|
||||
public static final BCLBiome BASALT_DELTAS_BIOME = registerNetherBiome(getFromRegistry(new ResourceLocation("basalt_deltas")));
|
||||
public static final BCLBiome NETHER_WASTES_BIOME = registerNetherBiome(getFromRegistry(Biomes.NETHER_WASTES));
|
||||
public static final BCLBiome CRIMSON_FOREST_BIOME = registerNetherBiome(getFromRegistry(Biomes.CRIMSON_FOREST));
|
||||
public static final BCLBiome WARPED_FOREST_BIOME = registerNetherBiome(getFromRegistry(Biomes.WARPED_FOREST));
|
||||
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = registerNetherBiome(getFromRegistry(Biomes.SOUL_SAND_VALLEY));
|
||||
public static final BCLBiome BASALT_DELTAS_BIOME = registerNetherBiome(getFromRegistry(Biomes.BASALT_DELTAS));
|
||||
|
||||
public static final BCLBiome THE_END = registerEndLandBiome(getFromRegistry(new ResourceLocation("the_end")));
|
||||
public static final BCLBiome END_MIDLANDS = registerSubBiome(THE_END, getFromRegistry(new ResourceLocation("end_midlands")), 0.5F);
|
||||
public static final BCLBiome END_HIGHLANDS = registerSubBiome(THE_END, getFromRegistry(new ResourceLocation("end_highlands")), 0.5F);
|
||||
public static final BCLBiome THE_END = registerEndLandBiome(getFromRegistry(Biomes.THE_END));
|
||||
public static final BCLBiome END_MIDLANDS = registerSubBiome(THE_END, getFromRegistry(Biomes.END_MIDLANDS), 0.5F);
|
||||
public static final BCLBiome END_HIGHLANDS = registerSubBiome(THE_END, getFromRegistry(Biomes.END_HIGHLANDS), 0.5F);
|
||||
|
||||
public static final BCLBiome END_BARRENS = registerEndVoidBiome(getFromRegistry(new ResourceLocation("end_barrens")));
|
||||
public static final BCLBiome SMALL_END_ISLANDS = registerEndVoidBiome(getFromRegistry(new ResourceLocation("small_end_islands")));
|
||||
|
@ -330,8 +330,13 @@ public class BiomeAPI {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public static Biome getFromRegistry(ResourceLocation biomeID) {
|
||||
return BuiltinRegistries.BIOME.get(biomeID);
|
||||
public static Biome getFromRegistry(ResourceLocation key) {
|
||||
return BuiltinRegistries.BIOME.get(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Biome getFromRegistry(ResourceKey<Biome> key) {
|
||||
return BuiltinRegistries.BIOME.get(key);
|
||||
}
|
||||
|
||||
public static boolean isDatapackBiome(ResourceLocation biomeID) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package ru.bclib.world.generator;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.RegistryLookupCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -45,14 +46,26 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
|||
|
||||
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
|
||||
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();
|
||||
|
||||
this.possibleBiomes.forEach(biome -> {
|
||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
bclBiome.updateActualBiomes(biomeRegistry);
|
||||
if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key)) {
|
||||
if (!BiomeAPI.hasBiome(key)) {
|
||||
BCLBiome bclBiome = new BCLBiome(key, biome, 1, 1);
|
||||
BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||
}
|
||||
else {
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME && !bclBiome.hasParentBiome()) {
|
||||
if (!BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) && !BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key)) {
|
||||
BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BiomeAPI.END_LAND_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||
BiomeAPI.END_VOID_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||
|
||||
BiomeAPI.END_LAND_BIOME_PICKER.rebuild();
|
||||
BiomeAPI.END_VOID_BIOME_PICKER.rebuild();
|
||||
|
||||
|
@ -74,9 +87,14 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
|||
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
return biomeRegistry.stream().filter(biome -> {
|
||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||
return BiomeAPI.END_LAND_BIOME_PICKER.contains(key) ||
|
||||
BiomeAPI.END_VOID_BIOME_PICKER.contains(key) ||
|
||||
(BiomeAPI.isDatapackBiome(key) && biome.getBiomeCategory() == BiomeCategory.THEEND);
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||
if (bclBiome.hasParentBiome()) {
|
||||
bclBiome = bclBiome.getParentBiome();
|
||||
}
|
||||
key = bclBiome.getID();
|
||||
}
|
||||
return BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(key) || BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(key) || (biome.getBiomeCategory() == BiomeCategory.THEEND && BiomeAPI.isDatapackBiome(key));
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,14 +30,24 @@ public class BCLibNetherBiomeSource extends BiomeSource {
|
|||
super(getBiomes(biomeRegistry));
|
||||
|
||||
BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
|
||||
|
||||
this.possibleBiomes.forEach(biome -> {
|
||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
bclBiome.updateActualBiomes(biomeRegistry);
|
||||
if (!BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key)) {
|
||||
if (!BiomeAPI.hasBiome(key)) {
|
||||
BCLBiome bclBiome = new BCLBiome(key, biome, 1, 1);
|
||||
BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||
}
|
||||
else {
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME && !bclBiome.hasParentBiome()) {
|
||||
if (!BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key)) {
|
||||
BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BiomeAPI.NETHER_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
|
||||
BiomeAPI.NETHER_BIOME_PICKER.rebuild();
|
||||
|
||||
this.biomeMap = new BiomeMap(seed, GeneratorOptions.getBiomeSizeNether(), BiomeAPI.NETHER_BIOME_PICKER);
|
||||
|
@ -48,8 +58,14 @@ public class BCLibNetherBiomeSource extends BiomeSource {
|
|||
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
return biomeRegistry.stream().filter(biome -> {
|
||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||
return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) ||
|
||||
(BiomeAPI.isDatapackBiome(key) && biome.getBiomeCategory() == BiomeCategory.NETHER);
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
if (bclBiome != BiomeAPI.EMPTY_BIOME) {
|
||||
if (bclBiome.hasParentBiome()) {
|
||||
bclBiome = bclBiome.getParentBiome();
|
||||
}
|
||||
key = bclBiome.getID();
|
||||
}
|
||||
return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) || (biome.getBiomeCategory() == BiomeCategory.NETHER && BiomeAPI.isDatapackBiome(key));
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,16 +14,22 @@ import java.util.Set;
|
|||
public class BiomePicker {
|
||||
private final Set<ResourceLocation> immutableIDs = Sets.newHashSet();
|
||||
private final List<BCLBiome> biomes = Lists.newArrayList();
|
||||
private int biomeCount = 0;
|
||||
private WeighTree<BCLBiome> tree;
|
||||
private int biomeCount = 0;
|
||||
|
||||
public void addBiome(BCLBiome biome) {
|
||||
if (immutableIDs.contains(biome.getID())) {
|
||||
return;
|
||||
}
|
||||
immutableIDs.add(biome.getID());
|
||||
biomes.add(biome);
|
||||
biomeCount++;
|
||||
}
|
||||
|
||||
public void addBiomeMutable(BCLBiome biome) {
|
||||
if (immutableIDs.contains(biome.getID())) {
|
||||
return;
|
||||
}
|
||||
biomes.add(biome);
|
||||
}
|
||||
|
||||
|
@ -45,10 +51,6 @@ public class BiomePicker {
|
|||
return immutableIDs.contains(id);
|
||||
}
|
||||
|
||||
public boolean contains(ResourceLocation id) {
|
||||
return biomes.contains(id);
|
||||
}
|
||||
|
||||
public void removeMutableBiome(ResourceLocation id) {
|
||||
for (int i = biomeCount; i < biomes.size(); i++) {
|
||||
BCLBiome biome = biomes.get(i);
|
||||
|
@ -63,10 +65,10 @@ public class BiomePicker {
|
|||
if (biomes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
WeightedList<BCLBiome> list = new WeightedList<BCLBiome>();
|
||||
biomes.forEach((biome) -> {
|
||||
WeightedList<BCLBiome> list = new WeightedList<>();
|
||||
biomes.forEach(biome -> {
|
||||
list.add(biome, biome.getGenChance());
|
||||
});
|
||||
tree = new WeighTree<BCLBiome>(list);
|
||||
tree = new WeighTree<>(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public class GeneratorOptions {
|
|||
private static int biomeSizeEndLand;
|
||||
private static int biomeSizeEndVoid;
|
||||
private static Function<Point, Boolean> endLandFunction;
|
||||
private static boolean farEndBiomes;
|
||||
private static boolean farEndBiomes = true;
|
||||
|
||||
public static void init() {
|
||||
biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue