From b09234ee3f456fb308406250519fedea5d40fd08 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 30 Aug 2022 21:50:52 +1000 Subject: [PATCH] SPIGOT-7131: Chunk snapshot returned by World#getEmptyChunkSnapshot(int,int,boolean,boolean) thinks every block has PLAINS biome By: DerFrZocker --- .../src/main/java/org/bukkit/craftbukkit/CraftChunk.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 9818d62714..d580762791 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -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 iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); DataPaletteBlock>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null; + Codec>> 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>) biomeCodec.parse(DynamicOpsNBT.INSTANCE, biomeCodec.encodeStart(DynamicOpsNBT.INSTANCE, actual.getSection(i).getBiomes()).get().left().get()).get().left().get(); } }