From 1eb535f14f8e75d17eeb39f8a2a23ee67b7d053a Mon Sep 17 00:00:00 2001 From: Irtimaled Date: Tue, 7 Apr 2015 14:40:17 +0100 Subject: [PATCH] Copy fortress.dat from vanilla location Fixes #1747 If the dat file isn't in the dimension specific folder but is present in the vanilla data folder then copy it over. --- .../common/WorldSpecificSaveHandler.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java b/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java index 0dd9d6cc9..c4d6efeb3 100644 --- a/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java +++ b/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java @@ -1,6 +1,8 @@ package net.minecraftforge.common; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import net.minecraft.world.chunk.storage.IChunkLoader; import net.minecraft.world.storage.IPlayerFileData; @@ -10,6 +12,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.storage.WorldInfo; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldServer; +import net.minecraftforge.fml.common.FMLLog; //Class used internally to provide the world specific data directories. @@ -43,7 +46,23 @@ public class WorldSpecificSaveHandler implements ISaveHandler dataDir = new File(world.getChunkSaveLocation(), "data"); dataDir.mkdirs(); } - return new File(dataDir, name + ".dat"); + File file = new File(dataDir, name + ".dat"); + if (!file.exists() && name.equalsIgnoreCase("FORTRESS")) + { + File parentFile = parent.getMapFileFromName(name); + if (parentFile.exists()) + { + try + { + Files.copy(parentFile.toPath(), file.toPath()); + } + catch (IOException e) + { + FMLLog.log(Level.ERROR, e, "A critical error occured copying fortress.dat to world specific dat folder - new file will be created."); + } + } + } + return file; } }