Java Code Examples for net.minecraftforge.fml.relauncher.FMLInjectionData

The following are top voted examples for showing how to use net.minecraftforge.fml.relauncher.FMLInjectionData. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CustomWorldGen   File: FMLDeobfTweaker.java   View source code 5 votes vote down vote up
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader)
{
    // Deobfuscation transformer, always last, and the access transformer tweaker as well
    classLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.DeobfuscationTransformer");
    // Add all the access transformers now as well
    for (String transformer : CoreModManager.getAccessTransformers())
    {
        classLoader.registerTransformer(transformer);
    }
    classLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.ModAccessTransformer");
    classLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.ItemStackTransformer");
    try
    {
        FMLRelaunchLog.fine("Validating minecraft");
        Class<?> loaderClazz = Class.forName("net.minecraftforge.fml.common.Loader", true, classLoader);
        Method m = loaderClazz.getMethod("injectData", Object[].class);
        m.invoke(null, (Object)FMLInjectionData.data());
        m = loaderClazz.getMethod("instance");
        m.invoke(null);
        FMLRelaunchLog.fine("Minecraft validated, launching...");
    }
    catch (Exception e)
    {
        // Load in the Loader, make sure he's ready to roll - this will initialize most of the rest of minecraft here
        System.out.println("A CRITICAL PROBLEM OCCURRED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
        throw new RuntimeException(e);
    }
}
 
Example 2
Project: CustomWorldGen   File: Configuration.java   View source code 5 votes vote down vote up
/**
 * Create a configuration file for the file given in parameter with the provided config version number.
 */
private void runConfiguration(File file, String configVersion)
{
    this.file = file;
    this.definedConfigVersion = configVersion;
    String basePath = ((File)(FMLInjectionData.data()[6])).getAbsolutePath().replace(File.separatorChar, '/').replace("/.", "");
    String path = file.getAbsolutePath().replace(File.separatorChar, '/').replace("/./", "/").replace(basePath, "");
    if (PARENT != null)
    {
        PARENT.setChild(path, this);
        isChild = true;
    }
    else
    {
        fileName = path;
        try
        {
            load();
        }
        catch (Throwable e)
        {
            File fileBak = new File(file.getAbsolutePath() + "_" +
                    new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".errored");
            FMLLog.severe("An exception occurred while loading config file %s. This file will be renamed to %s " +
                    "and a new config file will be generated.", file.getName(), fileBak.getName());
            e.printStackTrace();

            file.renameTo(fileBak);
            load();
        }
    }
}
 
Example 3
Project: CodeChickenCore   File: CodeChickenCorePlugin.java   View source code 5 votes vote down vote up
public CodeChickenCorePlugin() {
    if (minecraftDir != null) {
        return;//get called twice, once for IFMLCallHook
    }

    minecraftDir = (File) FMLInjectionData.data()[6];
    currentMcVersion = (String) FMLInjectionData.data()[4];

    loadConfig();
}
 
Example 4
Project: CodeChickenCore   File: CCUpdateChecker.java   View source code 4 votes vote down vote up
public static String mcVersion() {
    return (String) FMLInjectionData.data()[4];
}
 
Example 5
Project: CCTweaks   File: CCTweaks.java   View source code 4 votes vote down vote up
public static void initConfig() {
    if (configFile == null) {
        configFile = new ConfigFile(new File((File) FMLInjectionData.data()[6], "config/CodeChickenTweaks.cfg")).setComment("CodeChickenTweaks configuration file.\n" + "Deleting any element will restore it to it's default value");
    }
}
 
Example 6
Project: CodeChickenLib   File: CommonUtils.java   View source code 4 votes vote down vote up
public static File getMinecraftDir() {
    return (File) FMLInjectionData.data()[6];
}
 
Example 7
Project: Gui_Desiner   File: GuiLoader.java   View source code 4 votes vote down vote up
public Importer(GuiLoader screen, String name) {
	this.screen = screen;
	File mcDir = (File) FMLInjectionData.data()[6];
	folder = new File(mcDir, "guis");
	file = new File(folder, name + ".gui");
}
 
Example 8
Project: Gui_Desiner   File: Saver.java   View source code 4 votes vote down vote up
public Saver(GuiDesigner guiDesigner, String name) {
    this.guiDesigner = guiDesigner;
    File mcDir = (File) FMLInjectionData.data()[6];
    folder = new File(mcDir, "guis");
    file = new File(folder, name + ".gui");
}
 
Example 9
Project: Gui_Desiner   File: Loader.java   View source code 4 votes vote down vote up
public Loader(String name) {
    File mcDir = (File) FMLInjectionData.data()[6];
    folder = new File(mcDir, "guis");
    file = new File(folder, name + ".gui");
}
 
Example 10
Project: Gui_Desiner   File: GuiLoader.java   View source code 4 votes vote down vote up
public Importer(GuiLoader screen, String name) {
	this.screen = screen;
	File mcDir = (File) FMLInjectionData.data()[6];
	folder = new File(mcDir, "guis");
	file = new File(folder, name + ".gui");
}
 
Example 11
Project: Gui_Desiner   File: Saver.java   View source code 4 votes vote down vote up
public Saver(GuiDesigner guiDesigner, String name) {
    this.guiDesigner = guiDesigner;
    File mcDir = (File) FMLInjectionData.data()[6];
    folder = new File(mcDir, "guis");
    file = new File(folder, name + ".gui");
}
 
Example 12
Project: Gui_Desiner   File: Loader.java   View source code 4 votes vote down vote up
public Loader(String name) {
    File mcDir = (File) FMLInjectionData.data()[6];
    folder = new File(mcDir, "guis");
    file = new File(folder, name + ".gui");
}