Skip to content

Commit

Permalink
Fixed Bulk Chunk 1.7 <-> 1.8 skylight reading
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 7, 2023
1 parent 69363c8 commit 7cb97dc
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.chunk;

import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.util.Pair;
import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -55,7 +56,18 @@ public void write(ByteBuf byteBuf, Chunk[] chunks) throws Exception {

byteBuf.writeShort(chunkCount);
byteBuf.writeInt(compressedSize);
byteBuf.writeBoolean(true); // hasSkyLight

boolean skyLight = false;
for (Chunk chunk : chunks) {
for (ChunkSection section : chunk.getSections()) {
if (section != null && section.getLight().hasSkyLight()) {
skyLight = true;
break;
}
}
}

byteBuf.writeBoolean(skyLight); // hasSkyLight
byteBuf.writeBytes(compressedData, 0, compressedSize);

for (int i = 0; i < chunkCount; i++) {
Expand Down

0 comments on commit 7cb97dc

Please sign in to comment.