Fixed missing caves in most biomes

This commit is contained in:
paulevsGitch 2021-06-21 12:16:54 +03:00
parent ff3194fedf
commit bed07d2ad7
3 changed files with 16 additions and 15 deletions

View file

@ -61,7 +61,6 @@ import ru.betterend.world.generator.BiomeType;
import ru.betterend.world.generator.GeneratorOptions; import ru.betterend.world.generator.GeneratorOptions;
public class EndBiomes { public class EndBiomes {
private static final Map<ResourceLocation, EndBiome> ID_MAP = Maps.newHashMap();
public static final Set<ResourceLocation> FABRIC_VOID = Sets.newHashSet(); public static final Set<ResourceLocation> FABRIC_VOID = Sets.newHashSet();
private static final Set<ResourceLocation> SUBBIOMES_UNMUTABLES = Sets.newHashSet(); private static final Set<ResourceLocation> SUBBIOMES_UNMUTABLES = Sets.newHashSet();
@ -154,6 +153,7 @@ public class EndBiomes {
hasCaves = JsonFactory.getBoolean(element.getAsJsonObject(), "has_caves", true); hasCaves = JsonFactory.getBoolean(element.getAsJsonObject(), "has_caves", true);
} }
EndBiome endBiome = new EndBiome(id, biome, fog, chance, hasCaves); EndBiome endBiome = new EndBiome(id, biome, fog, chance, hasCaves);
System.out.println("Added biome: " + endBiome);
if (isVoid) { if (isVoid) {
VOID_BIOMES.addBiomeMutable(endBiome); VOID_BIOMES.addBiomeMutable(endBiome);
@ -161,7 +161,7 @@ public class EndBiomes {
else { else {
LAND_BIOMES.addBiomeMutable(endBiome); LAND_BIOMES.addBiomeMutable(endBiome);
} }
ID_MAP.put(id, endBiome); BiomeAPI.registerBiome(endBiome);
} }
} }
} }
@ -274,7 +274,7 @@ public class EndBiomes {
parent.addSubBiome(endBiome); parent.addSubBiome(endBiome);
SUBBIOMES.add(endBiome); SUBBIOMES.add(endBiome);
SUBBIOMES_UNMUTABLES.add(endBiome.getID()); SUBBIOMES_UNMUTABLES.add(endBiome.getID());
ID_MAP.put(endBiome.getID(), endBiome); BiomeAPI.registerBiome(endBiome);
} }
return endBiome; return endBiome;
} }
@ -291,7 +291,6 @@ public class EndBiomes {
parent.addSubBiome(biome); parent.addSubBiome(biome);
SUBBIOMES.add(biome); SUBBIOMES.add(biome);
SUBBIOMES_UNMUTABLES.add(biome.getID()); SUBBIOMES_UNMUTABLES.add(biome.getID());
ID_MAP.put(biome.getID(), biome);
BiomeAPI.addEndLandBiomeToFabricApi(biome); BiomeAPI.addEndLandBiomeToFabricApi(biome);
} }
return biome; return biome;
@ -307,7 +306,6 @@ public class EndBiomes {
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) { if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
BiomeAPI.registerBiome(biome); BiomeAPI.registerBiome(biome);
addToPicker(biome, type); addToPicker(biome, type);
ID_MAP.put(biome.getID(), biome);
if (type == BiomeType.LAND) { if (type == BiomeType.LAND) {
BiomeAPI.addEndLandBiomeToFabricApi(biome); BiomeAPI.addEndLandBiomeToFabricApi(biome);
} }
@ -328,7 +326,6 @@ public class EndBiomes {
BiomeAPI.registerBiome(biome); BiomeAPI.registerBiome(biome);
SUBBIOMES.add(biome); SUBBIOMES.add(biome);
SUBBIOMES_UNMUTABLES.add(biome.getID()); SUBBIOMES_UNMUTABLES.add(biome.getID());
ID_MAP.put(biome.getID(), biome);
BiomeAPI.addEndLandBiomeToFabricApi(biome); BiomeAPI.addEndLandBiomeToFabricApi(biome);
} }
return biome; return biome;
@ -341,7 +338,7 @@ public class EndBiomes {
*/ */
public static void addSubBiomeIntegration(EndBiome biome, ResourceLocation parent) { public static void addSubBiomeIntegration(EndBiome biome, ResourceLocation parent) {
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) { if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
EndBiome parentBiome = ID_MAP.get(parent); BCLBiome parentBiome = BiomeAPI.getBiome(parent);
if (parentBiome != null && !parentBiome.containsSubBiome(biome)) { if (parentBiome != null && !parentBiome.containsSubBiome(biome)) {
parentBiome.addSubBiome(biome); parentBiome.addSubBiome(biome);
} }
@ -369,7 +366,6 @@ public class EndBiomes {
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) { if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
BiomeAPI.registerBiome(biome); BiomeAPI.registerBiome(biome);
CAVE_BIOMES.addBiome(biome); CAVE_BIOMES.addBiome(biome);
ID_MAP.put(biome.getID(), biome);
} }
return biome; return biome;
} }
@ -377,8 +373,4 @@ public class EndBiomes {
public static EndCaveBiome getCaveBiome(int x, int z) { public static EndCaveBiome getCaveBiome(int x, int z) {
return (EndCaveBiome) caveBiomeMap.getBiome(x, z); return (EndCaveBiome) caveBiomeMap.getBiome(x, z);
} }
public static boolean hasBiome(ResourceLocation biomeID) {
return ID_MAP.containsKey(biomeID);
}
} }

View file

@ -5,14 +5,22 @@ import net.minecraft.world.level.biome.Biome;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.biomes.BCLBiomeDef; import ru.bclib.world.biomes.BCLBiomeDef;
import ru.betterend.config.Configs; import ru.betterend.config.Configs;
import ru.betterend.registry.EndFeatures;
public class EndBiome extends BCLBiome { public class EndBiome extends BCLBiome {
public EndBiome(BCLBiomeDef definition) { public EndBiome(BCLBiomeDef def) {
super(definition.loadConfigValues(Configs.BIOME_CONFIG)); super(updateDef(def));
} }
public EndBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance, boolean hasCaves) { public EndBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance, boolean hasCaves) {
super(id, biome, fogDensity, genChance); super(id, biome, fogDensity, genChance);
this.addCustomData("has_caves", hasCaves); this.addCustomData("has_caves", hasCaves);
} }
private static BCLBiomeDef updateDef(BCLBiomeDef def) {
def.loadConfigValues(Configs.BIOME_CONFIG);
EndFeatures.addDefaultFeatures(def);
return def;
}
} }

View file

@ -63,7 +63,8 @@ public class BetterEndBiomeSource extends BiomeSource {
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) { private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
List<Biome> list = Lists.newArrayList(); List<Biome> list = Lists.newArrayList();
biomeRegistry.forEach((biome) -> { biomeRegistry.forEach((biome) -> {
if (EndBiomes.hasBiome(biomeRegistry.getKey(biome))) { BCLBiome bclBiome = BiomeAPI.getBiome(biomeRegistry.getKey(biome));
if (bclBiome instanceof EndBiome) {
list.add(biome); list.add(biome);
} }
}); });