Java 类net.minecraftforge.fml.common.asm.transformers.ModAccessTransformer 实例源码

项目:CodeChickenCore    文件:DepLoader.java   
/**
 * Looks for FMLCorePlugin attributes and adds to CoreModManager
 */
private boolean searchCoreMod(File coreMod) {
    JarFile jar = null;
    Attributes mfAttributes;
    try {
        jar = new JarFile(coreMod);
        if (jar.getManifest() == null) {
            return false;
        }

        ModAccessTransformer.addJar(jar);
        mfAttributes = jar.getManifest().getMainAttributes();
    } catch (IOException ioe) {
        FMLRelaunchLog.log(Level.ERROR, ioe, "Unable to read the jar file %s - ignoring", coreMod.getName());
        return false;
    } finally {
        try {
            if (jar != null) {
                jar.close();
            }
        } catch (IOException ignored) {
        }
    }

    String fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin");
    if (fmlCorePlugin == null) {
        return false;
    }

    addClasspath(coreMod);

    try {
        if (!mfAttributes.containsKey(new Attributes.Name("FMLCorePluginContainsFMLMod"))) {
            FMLRelaunchLog.finer("Adding %s to the list of known coremods, it will not be examined again", coreMod.getName());
            CoreModManager.getIgnoredMods().add(coreMod.getName());
        } else {
            FMLRelaunchLog.finer("Found FMLCorePluginContainsFMLMod marker in %s, it will be examined later for regular @Mod instances", coreMod.getName());
            CoreModManager.getReparseableCoremods().add(coreMod.getName());
        }
        Method m_loadCoreMod = CoreModManager.class.getDeclaredMethod("loadCoreMod", LaunchClassLoader.class, String.class, File.class);
        m_loadCoreMod.setAccessible(true);
        m_loadCoreMod.invoke(null, loader, fmlCorePlugin, coreMod);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    return true;
}
项目:T.E.C.H    文件:DepLoader.java   
/**
 * Looks for FMLCorePlugin attributes and adds to CoreModManager
 */
private boolean searchCoreMod(File coreMod) {
    JarFile jar = null;
    Attributes mfAttributes;
    try {
        jar = new JarFile(coreMod);
        if (jar.getManifest() == null) {
            return false;
        }

        ModAccessTransformer.addJar(jar);
        mfAttributes = jar.getManifest().getMainAttributes();
    } catch (IOException ioe) {
        FMLRelaunchLog.log(Level.ERROR, ioe, "Unable to read the jar file %s - ignoring", coreMod.getName());
        return false;
    } finally {
        try {
            if (jar != null) {
                jar.close();
            }
        } catch (IOException ignored) {
        }
    }

    String fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin");
    if (fmlCorePlugin == null) {
        return false;
    }

    addClasspath(coreMod);

    try {
        if (!mfAttributes.containsKey(new Attributes.Name("FMLCorePluginContainsFMLMod"))) {
            FMLRelaunchLog.finer("Adding %s to the list of known coremods, it will not be examined again", coreMod.getName());
            CoreModManager.getIgnoredMods().add(coreMod.getName());
        } else {
            FMLRelaunchLog.finer("Found FMLCorePluginContainsFMLMod marker in %s, it will be examined later for regular @Mod instances", coreMod.getName());
            CoreModManager.getReparseableCoremods().add(coreMod.getName());
        }
        Method m_loadCoreMod = CoreModManager.class.getDeclaredMethod("loadCoreMod", LaunchClassLoader.class, String.class, File.class);
        m_loadCoreMod.setAccessible(true);
        m_loadCoreMod.invoke(null, loader, fmlCorePlugin, coreMod);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    return true;
}