@@ -35,18 +35,18 @@ private PolarReader() {}
3535 byte minSection = buffer .read (BYTE ), maxSection = buffer .read (BYTE );
3636 assertThat (minSection < maxSection , "Invalid section range" );
3737
38- var chunks = buffer .readCollection (b -> readChunk (b , maxSection - minSection + 1 ));
38+ var chunks = buffer .readCollection (b -> readChunk (version , b , maxSection - minSection + 1 ));
3939
4040 return new PolarWorld (version , compression , minSection , maxSection , chunks );
4141 }
4242
43- private static @ NotNull PolarChunk readChunk (@ NotNull NetworkBuffer buffer , int sectionCount ) {
43+ private static @ NotNull PolarChunk readChunk (short version , @ NotNull NetworkBuffer buffer , int sectionCount ) {
4444 var chunkX = buffer .read (VAR_INT );
4545 var chunkZ = buffer .read (VAR_INT );
4646
4747 var sections = new PolarSection [sectionCount ];
4848 for (int i = 0 ; i < sectionCount ; i ++) {
49- sections [i ] = readSection (buffer );
49+ sections [i ] = readSection (version , buffer );
5050 }
5151
5252 var blockEntities = buffer .readCollection (PolarReader ::readBlockEntity );
@@ -68,7 +68,7 @@ private PolarReader() {}
6868 );
6969 }
7070
71- private static @ NotNull PolarSection readSection (@ NotNull NetworkBuffer buffer ) {
71+ private static @ NotNull PolarSection readSection (short version , @ NotNull NetworkBuffer buffer ) {
7272 // If section is empty exit immediately
7373 if (buffer .read (BOOLEAN )) return new PolarSection ();
7474
@@ -93,7 +93,13 @@ private PolarReader() {}
9393 }
9494
9595 byte [] blockLight = null , skyLight = null ;
96- if (buffer .read (BOOLEAN )) {
96+
97+ if (version > PolarWorld .VERSION_UNIFIED_LIGHT ) {
98+ if (buffer .read (BOOLEAN ))
99+ blockLight = buffer .readBytes (2048 );
100+ if (buffer .read (BOOLEAN ))
101+ skyLight = buffer .readBytes (2048 );
102+ } else {
97103 blockLight = buffer .readBytes (2048 );
98104 skyLight = buffer .readBytes (2048 );
99105 }
0 commit comments