#1278: Return correct default light in chunk snapshot

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2023-10-15 20:20:30 +11:00
parent 4dc97ffa9d
commit 9713b3f255

View file

@ -56,7 +56,8 @@ public class CraftChunk implements Chunk {
private final int x;
private final int z;
private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new DataPaletteBlock<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES);
private static final byte[] emptyLight = new byte[2048];
private static final byte[] FULL_LIGHT = new byte[2048];
private static final byte[] EMPTY_LIGHT = new byte[2048];
public CraftChunk(net.minecraft.world.level.chunk.Chunk chunk) {
worldServer = chunk.level;
@ -318,14 +319,14 @@ public class CraftChunk implements Chunk {
LevelLightEngine lightengine = worldServer.getLightEngine();
NibbleArray skyLightArray = lightengine.getLayerListener(EnumSkyBlock.SKY).getDataLayerData(SectionPosition.of(x, chunk.getSectionYFromSectionIndex(i), z)); // SPIGOT-7498: Convert section index
if (skyLightArray == null) {
sectionSkyLights[i] = emptyLight;
sectionSkyLights[i] = worldServer.dimensionType().hasSkyLight() ? FULL_LIGHT : EMPTY_LIGHT;
} else {
sectionSkyLights[i] = new byte[2048];
System.arraycopy(skyLightArray.getData(), 0, sectionSkyLights[i], 0, 2048);
}
NibbleArray emitLightArray = lightengine.getLayerListener(EnumSkyBlock.BLOCK).getDataLayerData(SectionPosition.of(x, chunk.getSectionYFromSectionIndex(i), z)); // SPIGOT-7498: Convert section index
if (emitLightArray == null) {
sectionEmitLights[i] = emptyLight;
sectionEmitLights[i] = EMPTY_LIGHT;
} else {
sectionEmitLights[i] = new byte[2048];
System.arraycopy(emitLightArray.getData(), 0, sectionEmitLights[i], 0, 2048);
@ -397,8 +398,8 @@ public class CraftChunk implements Chunk {
for (int i = 0; i < hSection; i++) {
blockIDs[i] = emptyBlockIDs;
skyLight[i] = emptyLight;
emitLight[i] = emptyLight;
skyLight[i] = world.getHandle().dimensionType().hasSkyLight() ? FULL_LIGHT : EMPTY_LIGHT;
emitLight[i] = EMPTY_LIGHT;
empty[i] = true;
if (biome != null) {
@ -416,6 +417,6 @@ public class CraftChunk implements Chunk {
}
static {
Arrays.fill(emptyLight, (byte) 0xFF);
Arrays.fill(FULL_LIGHT, (byte) 0xFF);
}
}