Improve accuracy of possible biomes check

This commit is contained in:
embeddedt 2026-05-23 12:50:48 -04:00
parent 50cedfc699
commit f8d2425242
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -26,8 +26,15 @@ public class NoiseBasedChunkGeneratorMixin {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static void mfix$accumulate(Set<ResourceKey<Biome>> chunkBiomes, LevelChunkSection section) { private static void mfix$accumulate(Set<ResourceKey<Biome>> chunkBiomes, LevelChunkSection section) {
var palette = ((ExtendedPalettedContainer<Holder<Biome>>)section.getBiomes()).mfix$getPalette(); var palette = ((ExtendedPalettedContainer<Holder<Biome>>)section.getBiomes()).mfix$getPalette();
for (int i = 0; i < palette.getSize(); i++) { if (palette.getSize() == 1) {
chunkBiomes.add(palette.valueFor(i).unwrapKey().orElseThrow()); // No need to iterate the storage itself, as there can only be one value
chunkBiomes.add(palette.valueFor(0).unwrapKey().orElseThrow());
} else {
// Use getAll() rather than raw palette iteration. PalettedContainer.recreate() seeds the new
// palette with Biomes.PLAINS (the initial default), leaving a stale palette entry even after
// fillBiomesFromNoise replaces all cells with real biomes. getAll() only visits entries that
// are actually referenced in the backing storage, so stale entries are correctly excluded.
section.getBiomes().getAll(holder -> chunkBiomes.add(holder.unwrapKey().orElseThrow()));
} }
} }