2014-04-29 00:35:55 +10:00
|
|
|
package codechicken.core;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
2014-07-10 21:31:43 +10:00
|
|
|
import cpw.mods.fml.relauncher.FMLInjectionData;
|
2014-08-04 23:15:48 +10:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.EntityList;
|
2014-04-29 00:35:55 +10:00
|
|
|
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 getMinecraftDir() {
|
2014-07-10 21:31:43 +10:00
|
|
|
return (File) FMLInjectionData.data()[6];
|
2014-04-29 00:35:55 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2014-08-04 23:15:48 +10:00
|
|
|
|
|
|
|
|
public static void registerHandledEntity(Class<? extends Entity> entityClass, String identifier)
|
|
|
|
|
{
|
|
|
|
|
EntityList.classToStringMapping.put(entityClass, identifier);
|
|
|
|
|
EntityList.stringToClassMapping.put(identifier, entityClass);
|
|
|
|
|
}
|
2014-04-29 00:35:55 +10:00
|
|
|
}
|