File tree Expand file tree Collapse file tree
src/main/java/org/glavo/nbt/chunk Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,9 +80,11 @@ static ChunkRegion readRegion(InputContext context) throws IOException {
8080 throw new IOException ("Invalid chunk data length: " + chunkRawDataLength );
8181 }
8282
83+ long chunkRawContentLength = chunkRawDataLength - 1L ;
84+
8385 int compressType = context .rawReader .readUnsignedByte ();
8486 if (compressType > 128 ) {
85- if (chunkRawDataLength != 1 ) {
87+ if (chunkRawContentLength != 0L ) {
8688 throw new IOException ("Invalid chunk data length: %d (expected 1 for compression type %d)" .formatted (chunkRawDataLength , compressType ));
8789 }
8890
@@ -91,8 +93,8 @@ static ChunkRegion readRegion(InputContext context) throws IOException {
9193
9294 DataReader reader = switch (compressType ) {
9395 case 1 -> throw new IOException ("GZip compression is not supported yet." );
94- case 2 -> new ZlibDataReader (context , chunkRawDataLength - 1L );
95- case 3 -> new RawDataReader (context , chunkRawDataLength - 1L );
96+ case 2 -> new ZlibDataReader (context , chunkRawContentLength );
97+ case 3 -> new RawDataReader (context , chunkRawContentLength );
9698 case 4 -> throw new IOException ("LZ4 compression is not supported yet." );
9799 default -> throw new IOException ("Unsupported compression type: " + compressType );
98100 };
You can’t perform that action at this time.
0 commit comments