SPIGOT-7131: Chunk snapshot returned by World#getEmptyChunkSnapshot(int,int,boolean,boolean) thinks every block has PLAINS biome

This commit is contained in:
DerFrZocker 2022-08-30 21:50:52 +10:00 committed by md_5
parent 6c8a096118
commit 990d077dca
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -344,7 +344,7 @@ public class CraftChunk implements Chunk {
}
public static ChunkSnapshot getEmptyChunkSnapshot(int x, int z, CraftWorld world, boolean includeBiome, boolean includeBiomeTempRain) {
IChunkAccess actual = world.getHandle().getChunk(x, z, ChunkStatus.EMPTY);
IChunkAccess actual = world.getHandle().getChunk(x, z, (includeBiome || includeBiomeTempRain) ? ChunkStatus.BIOMES : ChunkStatus.EMPTY);
/* Fill with empty data */
int hSection = actual.getSectionsCount();
@ -354,6 +354,7 @@ public class CraftChunk implements Chunk {
boolean[] empty = new boolean[hSection];
IRegistry<BiomeBase> iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
DataPaletteBlock<Holder<BiomeBase>>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null;
Codec<PalettedContainerRO<Holder<BiomeBase>>> biomeCodec = DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
for (int i = 0; i < hSection; i++) {
blockIDs[i] = emptyBlockIDs;
@ -362,7 +363,7 @@ public class CraftChunk implements Chunk {
empty[i] = true;
if (biome != null) {
biome[i] = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES);
biome[i] = (DataPaletteBlock<Holder<BiomeBase>>) biomeCodec.parse(DynamicOpsNBT.INSTANCE, biomeCodec.encodeStart(DynamicOpsNBT.INSTANCE, actual.getSection(i).getBiomes()).get().left().get()).get().left().get();
}
}