package codechicken.core;

import java.io.File;
import java.lang.reflect.Array;
import java.util.LinkedList;
import java.util.List;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;

public class CommonUtils
{
    public static boolean isClient() {
        return FMLCommonHandler.instance().getSide().isClient();
    }

    public static File getSaveLocation(int dim) {
        File basesave = DimensionManager.getCurrentSaveRootDirectory();
        if (dim != 0)
            return new File(basesave, DimensionManager.getWorld(dim).provider.getSaveFolder());

        return basesave;
    }

    public static String getWorldName(World world) {
        return world.getWorldInfo().getWorldName();
    }

    public static int getDimension(World world) {
        return world.provider.dimensionId;
    }

    public static File getModsFolder() {
        return new File(getMinecraftDir(), "mods");
    }

    public static File getMinecraftDir() {
        return Minecraft.getMinecraft().mcDataDir;
    }

    public static String getRelativePath(File parent, File child) {
        if (parent.isFile() || !child.getPath().startsWith(parent.getPath()))
            return null;

        return child.getPath().substring(parent.getPath().length() + 1);
    }

    public static ModContainer findModContainer(String modID) {
        for (ModContainer mc : Loader.instance().getModList())
            if (modID.equals(mc.getModId()))
                return mc;

        return null;
    }
}

@@ -45,416 +45,101 @@
 le;%0A
-import java.lang.reflect.Array;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Aimport cpw.mods.fml.common.FMLCommonHandler;%0Aimport cpw.mods.fml.common.Loader;%0Aimport cpw.mods.fml.common.ModContainer;%0Aimport net.minecraft.block.Block;%0Aimport net.minecraft.client.Minecraft;%0Aimport net.minecraft.item.ItemStack;%0Aimport net.minecraft.util.ChatAllowedCharacters;%0Aimport net.minecraft.util.ChatComponentText
+%0Aimport cpw.mods.fml.common.FMLCommonHandler;%0Aimport cpw.mods.fml.relauncher.FMLInjectionData
 ;%0Aim
@@ -872,50 +872,8 @@
 ile 
-getModsFolder() %7B%0A        return new File(
 getM
@@ -889,118 +889,59 @@
 ir()
-, %22mods%22);
+ %7B
 %0A    
-%7D%0A%0A
     
-public static File getMinecraftDir() %7B%0A        return Minecraft.getMinecraft().mcDataDir
+return (File) FMLInjectionData.data()%5B6%5D
 ;%0A  
@@ -1199,235 +1199,7 @@
    %7D
-%0A%0A    public static ModContainer findModContainer(String modID) %7B%0A        for (ModContainer mc : Loader.instance().getModList())%0A            if (modID.equals(mc.getModId()))%0A                return mc;%0A%0A        return null;%0A    %7D
 %0A%7D%0A

Fix client reference in CommonUtils