Fix an exception when trying to access ungenerated chunks in an area that has no region file

This commit is contained in:
Blue (Lukas Rieger) 2020-01-06 20:26:06 +01:00
parent 76ea6e1918
commit 7d9b4d3f4b
3 changed files with 5 additions and 2 deletions

View File

@ -223,7 +223,7 @@ private boolean loadResources() throws IOException, ParseResourceException {
File resourcePackFolder = configFolder.toPath().resolve("resourcepacks").toFile();
resourcePackFolder.mkdirs();
File[] resourcePacks = resourcePackFolder.listFiles();
Arrays.sort(resourcePacks);
Arrays.sort(resourcePacks); //load resource packs in alphabetical order so you can reorder them by renaming
List<File> resources = new ArrayList<>(resourcePacks.length + 1);
resources.add(defaultResourceFile);

View File

@ -28,6 +28,7 @@
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.file.Path;
@ -225,6 +226,8 @@ private Chunk loadChunk(Vector2i chunkPos) throws IOException {
throw new IOException("invalid data tag: " + (tag == null ? "null" : tag.getClass().getName()));
}
} catch (FileNotFoundException ex) {
return Chunk.empty(this, chunkPos);
}
}

View File

@ -166,7 +166,7 @@ public synchronized void load() throws ExecutionException, IOException, Interrup
File resourcePackFolder = getConfigPath().resolve("resourcepacks").toFile();
resourcePackFolder.mkdirs();
File[] resourcePacks = resourcePackFolder.listFiles();
Arrays.sort(resourcePacks);
Arrays.sort(resourcePacks); //load resource packs in alphabetical order so you can reorder them by renaming
List<File> resources = new ArrayList<>(resourcePacks.length + 1);
resources.add(defaultResourceFile);