Files
CodeChickenCore/src/codechicken/core/CommonUtils.java
T

51 lines
1.6 KiB
Java
Raw Normal View History

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;
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(World world) {
File base = DimensionManager.getCurrentSaveRootDirectory();
return world.provider.dimensionId == 0 ? base : new File(base, world.provider.getSaveFolder());
}
2014-04-29 00:35:55 +10:00
public static File getSaveLocation(int dim) {
return getSaveLocation(DimensionManager.getWorld(dim));
2014-04-29 00:35:55 +10:00
}
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);
}
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
}