diff --git a/src/main/java/net/mcreator/customoregen/worldgen/LatitudeGameTest.java b/src/main/java/net/mcreator/customoregen/worldgen/LatitudeGameTest.java index 3952809e..1923c9d5 100644 --- a/src/main/java/net/mcreator/customoregen/worldgen/LatitudeGameTest.java +++ b/src/main/java/net/mcreator/customoregen/worldgen/LatitudeGameTest.java @@ -110,24 +110,59 @@ public class LatitudeGameTest { ResourceKey spawnKey = source.getNoiseBiome(0, 64 >> 2, 0, null).unwrapKey().orElse(null); + // Resolve the three surface tags so assertions can use tag membership (the source of + // truth) instead of a hardcoded vanilla-only biome list. This correctly counts BOP biomes. + Set> coldTag = resolveTagKeys(getter, BiomeBand.COLD.surfaceTag()); + Set> temperateTag = resolveTagKeys(getter, BiomeBand.TEMPERATE.surfaceTag()); + Set> hotTag = resolveTagKeys(getter, BiomeBand.HOT.surfaceTag()); + Set> coldOceans = new HashSet<>(List.of( + Biomes.FROZEN_OCEAN, Biomes.DEEP_FROZEN_OCEAN, Biomes.COLD_OCEAN, Biomes.DEEP_COLD_OCEAN, + Biomes.FROZEN_RIVER)); + Set> hotOceans = new HashSet<>(List.of( + Biomes.WARM_OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN)); + StringBuilder r = new StringBuilder(); r.append("Latitude GameTest Report (seed=").append(SEED).append(")\n\n"); r.append("Spawn @ (0,0): ").append(spawnKey).append("\n\n"); int total = global.values().stream().mapToInt(Integer::intValue).sum(); + r.append("Global biome distribution (top 20):\n"); global.entrySet().stream() .sorted(Map.Entry., Integer>comparingByValue().reversed()) + .limit(20) .forEach(e -> r.append(String.format(" %-45s %6.2f%%%n", e.getKey(), 100.0 * e.getValue() / total))); + + // Per-band breakdown for diagnostics. + for (BiomeBand band : BiomeBand.values()) { + Map, Integer> m = perBand.get(band); + int bt = m.values().stream().mapToInt(Integer::intValue).sum(); + if (bt == 0) continue; + r.append("\nBand ").append(band).append(" (").append(bt).append(" samples):\n"); + m.entrySet().stream() + .sorted(Map.Entry., Integer>comparingByValue().reversed()) + .limit(8) + .forEach(e -> r.append(String.format(" %-43s %6.2f%%%n", e.getKey(), 100.0 * e.getValue() / bt))); + } Files.writeString(OUT_DIR.resolve("latitude_report.txt"), r.toString()); - // ---- Assertions ---- + // ---- Assertions (tag-based: correctly counts vanilla + BOP biomes) ---- assertNotNull(spawnKey, "spawn biome resolved"); assertTrue(isSafeSpawn(spawnKey), "spawn must be a safe biome, was " + spawnKey); - double north = bandRatio(perBand.get(BiomeBand.FROZEN), frozenColdKeys()); - assertTrue(north > 60.0, "FROZEN band should be >60%% cold/frozen, was %.1f%%".formatted(north)); + Set> northExpected = new HashSet<>(); + northExpected.addAll(coldTag); + northExpected.addAll(coldOceans); + Set> undergroundCold = new HashSet<>(List.of( + Biomes.DRIPSTONE_CAVES, Biomes.DEEP_DARK)); + northExpected.addAll(undergroundCold); + double north = bandRatio(perBand.get(BiomeBand.FROZEN), northExpected); + assertTrue(north > 60.0, "FROZEN band should be >60%% cold/frozen (by tag), was %.1f%%".formatted(north)); - double south = bandRatio(perBand.get(BiomeBand.HOT), hotWarmKeys()); - assertTrue(south > 60.0, "HOT band should be >60%% warm/hot, was %.1f%%".formatted(south)); + Set> southExpected = new HashSet<>(); + southExpected.addAll(hotTag); + southExpected.addAll(hotOceans); + southExpected.add(Biomes.MANGROVE_SWAMP); + double south = bandRatio(perBand.get(BiomeBand.HOT), southExpected); + assertTrue(south > 60.0, "HOT band should be >60%% warm/hot (by tag), was %.1f%%".formatted(south)); Map, Integer> temperate = perBand.get(BiomeBand.TEMPERATE); int temperateTotal = temperate.values().stream().mapToInt(Integer::intValue).sum(); @@ -150,18 +185,11 @@ public class LatitudeGameTest { return 100.0 * match / total; } - private static Set> frozenColdKeys() { - return new HashSet<>(List.of(Biomes.SNOWY_PLAINS, Biomes.ICE_SPIKES, Biomes.SNOWY_TAIGA, Biomes.GROVE, - Biomes.SNOWY_SLOPES, Biomes.JAGGED_PEAKS, Biomes.FROZEN_PEAKS, Biomes.TAIGA, - Biomes.OLD_GROWTH_PINE_TAIGA, Biomes.OLD_GROWTH_SPRUCE_TAIGA, Biomes.WINDSWEPT_HILLS, - Biomes.WINDSWEPT_FOREST, Biomes.FROZEN_OCEAN, Biomes.DEEP_FROZEN_OCEAN, - Biomes.COLD_OCEAN, Biomes.DEEP_COLD_OCEAN, Biomes.FROZEN_RIVER)); - } - - private static Set> hotWarmKeys() { - return new HashSet<>(List.of(Biomes.DESERT, Biomes.BADLANDS, Biomes.WOODED_BADLANDS, - Biomes.ERODED_BADLANDS, Biomes.JUNGLE, Biomes.SPARSE_JUNGLE, Biomes.BAMBOO_JUNGLE, - Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.WARM_OCEAN)); + /** Resolve all biome keys that belong to a tag, via the real registry. */ + private static Set> resolveTagKeys(HolderGetter getter, net.minecraft.tags.TagKey tag) { + Set> keys = new HashSet<>(); + getter.get(tag).ifPresent(set -> set.forEach(h -> h.unwrapKey().ifPresent(keys::add))); + return keys; } private static boolean isSafeSpawn(ResourceKey key) {