@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); } }
/** * 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(); } } }
public CodeChickenCorePlugin() { if (minecraftDir != null) { return;//get called twice, once for IFMLCallHook } minecraftDir = (File) FMLInjectionData.data()[6]; currentMcVersion = (String) FMLInjectionData.data()[4]; loadConfig(); }
public static String mcVersion() { return (String) FMLInjectionData.data()[4]; }
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"); } }
public static File getMinecraftDir() { return (File) FMLInjectionData.data()[6]; }
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"); }
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"); }
public Loader(String name) { File mcDir = (File) FMLInjectionData.data()[6]; folder = new File(mcDir, "guis"); file = new File(folder, name + ".gui"); }