Skip to content

Commit bd0553b

Browse files
committed
Refactor ChunkRegion to use utility methods
1 parent 9c65359 commit bd0553b

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

src/main/java/org/glavo/nbt/chunk/ChunkRegion.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static ChunkRegion readRegion(RawDataReader rawReader) throws IOException {
4343
int[] timestamps = rawReader.readIntArray(ChunkUtils.CHUNKS_PRE_REGION);
4444
for (int z = 0; z < ChunkUtils.CHUNKS_PER_REGION_SIDE; z++) {
4545
for (int x = 0; x < ChunkUtils.CHUNKS_PER_REGION_SIDE; x++) {
46-
int index = x + z * ChunkUtils.CHUNKS_PER_REGION_SIDE;
46+
int index = ChunkUtils.toLocalIndex(x, z);
4747

4848
int info = diskInfo[index];
4949
int sectorOffset = info >>> 8;
@@ -84,7 +84,7 @@ static ChunkRegion readRegion(RawDataReader rawReader) throws IOException {
8484
throw new IOException("The chunk data is stored externally, and reading this data is not currently supported.");
8585
}
8686

87-
DataReader reader = switch (compressType) {
87+
BoundedDataReader reader = switch (compressType) {
8888
case 1 -> throw new IOException("GZip compression is not supported yet.");
8989
case 2 -> new ZlibDataReader(rawReader, chunkRawContentLength);
9090
case 3 -> new UncompressedDataReader(rawReader, chunkRawContentLength);

src/main/java/org/glavo/nbt/internal/input/ZlibDataReader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
public final class ZlibDataReader extends BoundedDataReader {
2525
static final RawDataReader.CacheKey<Inflater> INFLATER_CACHE_KEY = new RawDataReader.CacheKey<>() {
26-
2726
@Override
2827
protected Inflater create(RawDataReader rawReader) {
2928
return new Inflater();

0 commit comments

Comments
 (0)