package net.minecraftforge.common;

import java.io.File;

import net.minecraft.world.chunk.storage.IChunkLoader;
import net.minecraft.world.storage.IPlayerFileData;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.MinecraftException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.storage.WorldInfo;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;

//Class used internally to provide the world specific data directories.

public class WorldSpecificSaveHandler implements ISaveHandler
{
    private WorldServer world;
    private ISaveHandler parent;
    private File dataDir;

    public WorldSpecificSaveHandler(WorldServer world, ISaveHandler parent)
    {
        this.world = world;
        this.parent = parent;
    }

    @Override public WorldInfo loadWorldInfo() { return parent.loadWorldInfo(); }
    @Override public void checkSessionLock() throws MinecraftException { parent.checkSessionLock(); }
    @Override public IChunkLoader getChunkLoader(WorldProvider var1) { return parent.getChunkLoader(var1); }
    @Override public void saveWorldInfoWithPlayer(WorldInfo var1, NBTTagCompound var2) { parent.saveWorldInfoWithPlayer(var1, var2); }
    @Override public void saveWorldInfo(WorldInfo var1){ parent.saveWorldInfo(var1); }
    @Override public IPlayerFileData getPlayerNBTManager() { return parent.getPlayerNBTManager(); }
    @Override public void flush() { parent.flush(); }
    @Override public String getWorldDirectoryName() { return parent.getWorldDirectoryName(); }
    @Override public File getWorldDirectory() { return parent.getWorldDirectory(); }

    @Override
    public File getMapFileFromName(String name)
    {
        if (dataDir == null) //Delayed down here do that world has time to be initalized first.
        {
            dataDir = new File(world.getChunkSaveLocation(), "data");
            dataDir.mkdirs();
        }
        return new File(dataDir, name + ".dat");
    }

}

@@ -49,16 +49,72 @@
 io.File;
+%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;
 %0A%0Aimport
@@ -478,16 +478,61 @@
 dServer;
+%0Aimport net.minecraftforge.fml.common.FMLLog;
 %0A%0A//Clas
@@ -2042,22 +2042,27 @@
         
-return
+File file =
  new Fil
@@ -2084,21 +2084,607 @@
  + %22.dat%22);%0A
+        if (!file.exists() && name.equalsIgnoreCase(%22FORTRESS%22))%0A        %7B%0A            File parentFile = parent.getMapFileFromName(name);%0A            if (parentFile.exists())%0A            %7B%0A                try%0A                %7B%0A                    Files.copy(parentFile.toPath(), file.toPath());%0A                %7D%0A                catch (IOException e)%0A                %7B%0A                    FMLLog.log(Level.ERROR, e, %22A critical error occured copying fortress.dat to world specific dat folder - new file will be created.%22);%0A                %7D%0A            %7D%0A        %7D%0A        return file;%0A
     %7D%0A%0A%7D%0A

Copy fortress.dat from vanilla location