Skip to content

Commit

Permalink
Also search in parent folder for a level.dat
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Jan 18, 2020
1 parent 611109e commit ee38432
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit ee38432

Please sign in to comment.