Actually, we should not rely on an exception here

This commit is contained in:
Blue (Lukas Rieger) 2020-07-29 16:43:04 +02:00
parent 6e123e1c3f
commit aaeeeb136a

View File

@ -222,8 +222,11 @@ public Chunk getChunk(Vector2i chunkPos) throws IOException {
private Chunk loadChunk(Vector2i chunkPos) throws IOException {
Vector2i regionPos = chunkToRegion(chunkPos);
Path regionPath = getMCAFilePath(regionPos);
try (RandomAccessFile raf = new RandomAccessFile(regionPath.toFile(), "r")) {
File regionFile = regionPath.toFile();
if (!regionFile.exists()) return Chunk.empty(this, chunkPos);
try (RandomAccessFile raf = new RandomAccessFile(regionFile, "r")) {
int xzChunk = Math.floorMod(chunkPos.getY(), 32) * 32 + Math.floorMod(chunkPos.getX(), 32);
@ -253,8 +256,6 @@ private Chunk loadChunk(Vector2i chunkPos) throws IOException {
} else {
throw new IOException("invalid data tag: " + (tag == null ? "null" : tag.getClass().getName()));
}
} catch (FileNotFoundException ex) {
return Chunk.empty(this, chunkPos);
}
}