Also search in parent folder for a level.dat

This commit is contained in:
Blue (Lukas Rieger) 2020-01-18 12:47:06 +01:00
parent 611109ea91
commit ee384322d7

View File

@ -357,7 +357,15 @@ private Path getMCAFilePath(Vector2i region) {
public static MCAWorld load(Path worldFolder, UUID uuid, BlockIdMapper blockIdMapper, BlockPropertiesMapper blockPropertiesMapper, BiomeMapper biomeIdMapper) throws IOException {
try {
CompoundTag level = (CompoundTag) NBTUtil.readTag(worldFolder.resolve("level.dat").toFile());
File levelFile = new File(worldFolder.toFile(), "level.dat");
if (!levelFile.exists()) {
levelFile = new File(worldFolder.toFile().getParentFile(), "level.dat");
}
if (!levelFile.exists()) {
throw new FileNotFoundException("Could not find a level.dat file for this world!");
}
CompoundTag level = (CompoundTag) NBTUtil.readTag(levelFile);
CompoundTag levelData = level.getCompoundTag("Data");
String name = levelData.getString("LevelName");