java类cpw.mods.fml.relauncher.CoreModManager的实例源码

ClassDiscoverer.java 文件源码 项目:4Space-5 阅读 27 收藏 0 点赞 0 评论 0
private void findClasspathMods() {
    List<String> knownLibraries = ImmutableList.<String>builder()
            .addAll(modClassLoader.getDefaultLibraries())
            .addAll(CoreModManager.getLoadedCoremods()).build();
    File[] minecraftSources = modClassLoader.getParentSources();
    HashSet<String> searchedSources = new HashSet<String>();
    for (File minecraftSource : minecraftSources) {
        if (searchedSources.contains(minecraftSource.getAbsolutePath()))
            continue;
        searchedSources.add(minecraftSource.getAbsolutePath());

        if (minecraftSource.isFile()) {
            if (!knownLibraries.contains(minecraftSource.getName())) {
                FMLLog.fine("Found a minecraft related file at %s, examining for codechicken classes", minecraftSource.getAbsolutePath());
                try {
                    readFromZipFile(minecraftSource);
                } catch (Exception e) {
                    CodeChickenCorePlugin.logger.error("Failed to scan " + minecraftSource.getAbsolutePath() + ", the zip file is invalid", e);
                }
            }
        } else if (minecraftSource.isDirectory()) {
            FMLLog.fine("Found a minecraft related directory at %s, examining for codechicken classes", minecraftSource.getAbsolutePath());
            readFromDirectory(minecraftSource, minecraftSource);
        }
    }
}
CodeChickenCorePlugin.java 文件源码 项目:4Space-5 阅读 23 收藏 0 点赞 0 评论 0
private void injectDeobfPlugin() {
    try {
        Class<?> wrapperClass = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper");
        Constructor wrapperConstructor = wrapperClass.getConstructor(String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class);
        Field f_loadPlugins = CoreModManager.class.getDeclaredField("loadPlugins");
        wrapperConstructor.setAccessible(true);
        f_loadPlugins.setAccessible(true);
        ((List)f_loadPlugins.get(null)).add(2, wrapperConstructor.newInstance("CCCDeobfPlugin", new MCPDeobfuscationTransformer.LoadPlugin(), null, 0, new String[0]));
    } catch (Exception e) {
        logger.error("Failed to inject MCPDeobfuscation Transformer", e);
    }
}
ModDiscoverer.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 26 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir, File[] supplementalModFileCandidates)
{
    File[] modList = FileListHelper.sortFileList(modsDir, null);
    modList = FileListHelper.sortFileList(ObjectArrays.concat(modList, supplementalModFileCandidates, File.class));
    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
        @SuppressWarnings("unchecked")
        List<String> newTweaks = (List<String>) Launch.blackboard.get("TweakClasses");
        newTweaks.add("cpw.mods.fml.common.launcher.TerminalTweaker");
    }
    run = true;
}
FMLDeobfTweaker.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader)
{
    // Deobfuscation transformer, always last, and the access transformer tweaker as well
    if (!(Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment"))
    {
        classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
    }
    // Add all the access transformers now as well
    for (String transformer : CoreModManager.getAccessTransformers())
    {
        classLoader.registerTransformer(transformer);
    }
    classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ModAccessTransformer");
    classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ItemStackTransformer");
    try
    {
        FMLRelaunchLog.fine("Validating minecraft");
        Class<?> loaderClazz = Class.forName("cpw.mods.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 OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
        throw new RuntimeException(e);
    }
}
CollectiveFrameworkEarlyTransformerPlugin.java 文件源码 项目:CollectiveFramework 阅读 23 收藏 0 点赞 0 评论 0
private void injectNewTransformer() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException, IllegalAccessException, InvocationTargetException, InstantiationException {
    Class e = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper");
    Constructor wrapperConstructor = e.getConstructor(new Class[]{String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class});
    Field loadPlugins = CoreModManager.class.getDeclaredField("loadPlugins");
    wrapperConstructor.setAccessible(true);
    loadPlugins.setAccessible(true);
    ((List)loadPlugins.get((Object)null)).add(wrapperConstructor.newInstance(new Object[]{"CollectiveFrameworkPlugin", new CollectiveFrameworkTransformerPlugin(), null, Integer.valueOf(Integer.MAX_VALUE), new String[0]}));
    didInject = true;
}
ModDiscoverer.java 文件源码 项目:CauldronGit 阅读 27 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir)
{
    File[] modList = FileListHelper.sortFileList(modsDir, null);

    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:CauldronGit 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
        @SuppressWarnings("unchecked")
        List<String> newTweaks = (List<String>) Launch.blackboard.get("TweakClasses");
        newTweaks.add("cpw.mods.fml.common.launcher.TerminalTweaker");
    }
    run = true;
}
FMLDeobfTweaker.java 文件源码 项目:CauldronGit 阅读 34 收藏 0 点赞 0 评论 0
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader)
{
    // Deobfuscation transformer, always last, and the access transformer tweaker as well
    if (!(Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment"))
    {
        classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
    }
    // Add all the access transformers now as well
    for (String transformer : CoreModManager.getAccessTransformers())
    {
        classLoader.registerTransformer(transformer);
    }
    classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ModAccessTransformer");
    try
    {
        FMLRelaunchLog.fine("Validating minecraft");
        Class<?> loaderClazz = Class.forName("cpw.mods.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 OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
        throw new RuntimeException(e);
    }
}
HookLibPlugin.java 文件源码 项目:HookLib 阅读 16 收藏 0 点赞 0 评论 0
public static boolean getObfuscated() {
    if (!checked) {
        try {
            Field deobfField = CoreModManager.class.getDeclaredField("deobfuscatedEnvironment");
            deobfField.setAccessible(true);
            obf = !deobfField.getBoolean(null);
            FMLRelaunchLog.info("[HOOKLIB] " + " Obfuscated: " + obf);
        } catch (Exception e) {
            e.printStackTrace();
        }
        checked = true;
    }
    return obf;
}
LegacyJavaFixer.java 文件源码 项目:LegacyJavaFixer 阅读 23 收藏 0 点赞 0 评论 0
SortReplacement()
{
    try 
    {
        wrapperCls = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper", false, SortReplacement.class.getClassLoader());
        wrapperField = wrapperCls.getDeclaredField("sortIndex");
        wrapperField.setAccessible(true);
        tweakSorting = ReflectionHelper.getPrivateValue(CoreModManager.class, null, "tweakSorting");
    }
    catch (Exception e)
    {
        e.printStackTrace();
        Throwables.propagate(e);
    }
}
ModDiscoverer.java 文件源码 项目:Cauldron 阅读 23 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir)
{
    File[] modList = FileListHelper.sortFileList(modsDir, null);

    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:Cauldron 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
        @SuppressWarnings("unchecked")
        List<String> newTweaks = (List<String>) Launch.blackboard.get("TweakClasses");
        newTweaks.add("cpw.mods.fml.common.launcher.TerminalTweaker");
    }
    run = true;
}
FMLDeobfTweaker.java 文件源码 项目:Cauldron 阅读 30 收藏 0 点赞 0 评论 0
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader)
{
    // Deobfuscation transformer, always last, and the access transformer tweaker as well
    if (!(Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment"))
    {
        classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
    }
    // Add all the access transformers now as well
    for (String transformer : CoreModManager.getAccessTransformers())
    {
        classLoader.registerTransformer(transformer);
    }
    classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ModAccessTransformer");
    try
    {
        FMLRelaunchLog.fine("Validating minecraft");
        Class<?> loaderClazz = Class.forName("cpw.mods.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 OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
        throw new RuntimeException(e);
    }
}
ModDiscoverer.java 文件源码 项目:Cauldron 阅读 30 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir)
{
    File[] modList = FileListHelper.sortFileList(modsDir, null);

    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:Cauldron 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
        @SuppressWarnings("unchecked")
        List<String> newTweaks = (List<String>) Launch.blackboard.get("TweakClasses");
        newTweaks.add("cpw.mods.fml.common.launcher.TerminalTweaker");
    }
    run = true;
}
FMLDeobfTweaker.java 文件源码 项目:Cauldron 阅读 35 收藏 0 点赞 0 评论 0
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader)
{
    // Deobfuscation transformer, always last, and the access transformer tweaker as well
    if (!(Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment"))
    {
        classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
    }
    // Add all the access transformers now as well
    for (String transformer : CoreModManager.getAccessTransformers())
    {
        classLoader.registerTransformer(transformer);
    }
    classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ModAccessTransformer");
    try
    {
        FMLRelaunchLog.fine("Validating minecraft");
        Class<?> loaderClazz = Class.forName("cpw.mods.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 OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
        throw new RuntimeException(e);
    }
}
ModDiscoverer.java 文件源码 项目:Cauldron 阅读 26 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir)
{
    File[] modList = FileListHelper.sortFileList(modsDir, null);

    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:Cauldron 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
        @SuppressWarnings("unchecked")
        List<String> newTweaks = (List<String>) Launch.blackboard.get("TweakClasses");
        newTweaks.add("cpw.mods.fml.common.launcher.TerminalTweaker");
    }
    run = true;
}
FMLDeobfTweaker.java 文件源码 项目:Cauldron 阅读 30 收藏 0 点赞 0 评论 0
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader)
{
    // Deobfuscation transformer, always last, and the access transformer tweaker as well
    if (!(Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment"))
    {
        classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
    }
    // Add all the access transformers now as well
    for (String transformer : CoreModManager.getAccessTransformers())
    {
        classLoader.registerTransformer(transformer);
    }
    classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ModAccessTransformer");
    try
    {
        FMLRelaunchLog.fine("Validating minecraft");
        Class<?> loaderClazz = Class.forName("cpw.mods.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 OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
        throw new RuntimeException(e);
    }
}
ModDiscoverer.java 文件源码 项目:RuneCraftery 阅读 31 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir)
{
    File[] modList = modsDir.listFiles();
    // Sort the files into alphabetical order first
    Arrays.sort(modList, new Comparator<File>() {
        @Override
        public int compare(File o1, File o2)
        {
            return o1.getName().compareToIgnoreCase(o2.getName());
        }
    });

    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:RuneCraftery 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
    }
    run = true;
}
ModDiscoverer.java 文件源码 项目:RuneCraftery 阅读 22 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir)
{
    File[] modList = modsDir.listFiles();
    // Sort the files into alphabetical order first
    Arrays.sort(modList, new Comparator<File>() {
        @Override
        public int compare(File o1, File o2)
        {
            return o1.getName().compareToIgnoreCase(o2.getName());
        }
    });

    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:RuneCraftery 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
    }
    run = true;
}
SevenCommonsWrapper.java 文件源码 项目:SevenCommons 阅读 18 收藏 0 点赞 0 评论 0
private static void loadSevenCommons(File file) {
    try {
        Launch.classLoader.addURL(file.toURI().toURL());
        CoreModManager.getLoadedCoremods().add(file.getName());
        Method loadCoremod = CoreModManager.class.getDeclaredMethod("loadCoreMod", LaunchClassLoader.class, String.class, File.class);
        loadCoremod.setAccessible(true);
        loadCoremod.invoke(null, Launch.classLoader, SC_MAIN_CLASS, file);
    } catch (Exception e) {
        System.err.println("Failed to load SevenCommons as a Coremod!");
        e.printStackTrace();
        System.exit(1);
    }
}
ModDiscoverer.java 文件源码 项目:BetterNutritionMod 阅读 23 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir)
{
    File[] modList = modsDir.listFiles();
    // Sort the files into alphabetical order first
    Arrays.sort(modList);

    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
FMLInjectionAndSortingTweaker.java 文件源码 项目:BetterNutritionMod 阅读 25 收藏 0 点赞 0 评论 0
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
    if (!run)
    {
        // We sort the tweak list here so that it obeys the tweakordering
        CoreModManager.sortTweakList();
    }
    run = true;
}
ModDiscoverer.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 31 收藏 0 点赞 0 评论 0
public void findClasspathMods(ModClassLoader modClassLoader)
{
    List<String> knownLibraries = ImmutableList.<String>builder()
            // skip default libs
            .addAll(modClassLoader.getDefaultLibraries())
            // skip loaded coremods
            .addAll(CoreModManager.getLoadedCoremods())
            // skip reparse coremods here
            .addAll(CoreModManager.getReparseableCoremods())
            .build();
    File[] minecraftSources = modClassLoader.getParentSources();
    if (minecraftSources.length == 1 && minecraftSources[0].isFile())
    {
        FMLLog.fine("Minecraft is a file at %s, loading", minecraftSources[0].getAbsolutePath());
        candidates.add(new ModCandidate(minecraftSources[0], minecraftSources[0], ContainerType.JAR, true, true));
    }
    else
    {
        for (int i = 0; i < minecraftSources.length; i++)
        {
            if (minecraftSources[i].isFile())
            {
                if (knownLibraries.contains(minecraftSources[i].getName()))
                {
                    FMLLog.finer("Skipping known library file %s", minecraftSources[i].getAbsolutePath());
                }
                else
                {
                    FMLLog.fine("Found a minecraft related file at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath());
                    candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.JAR, i==0, true));
                }
            }
            else if (minecraftSources[i].isDirectory())
            {
                FMLLog.fine("Found a minecraft related directory at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath());
                candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.DIR, i==0, true));
            }
        }
    }

}
FMLInjectionAndSortingTweaker.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 23 收藏 0 点赞 0 评论 0
public FMLInjectionAndSortingTweaker()
{
    CoreModManager.injectCoreModTweaks(this);
    run = false;
}
ModDiscoverer.java 文件源码 项目:CauldronGit 阅读 28 收藏 0 点赞 0 评论 0
public void findClasspathMods(ModClassLoader modClassLoader)
{
    List<String> knownLibraries = ImmutableList.<String>builder()
            // skip default libs
            .addAll(modClassLoader.getDefaultLibraries())
            // skip loaded coremods
            .addAll(CoreModManager.getLoadedCoremods())
            // skip reparse coremods here
            .addAll(CoreModManager.getReparseableCoremods())
            .build();
    File[] minecraftSources = modClassLoader.getParentSources();
    if (minecraftSources.length == 1 && minecraftSources[0].isFile())
    {
        FMLLog.fine("Minecraft is a file at %s, loading", minecraftSources[0].getAbsolutePath());
        candidates.add(new ModCandidate(minecraftSources[0], minecraftSources[0], ContainerType.JAR, true, true));
    }
    else
    {
        for (int i = 0; i < minecraftSources.length; i++)
        {
            if (minecraftSources[i].isFile())
            {
                if (knownLibraries.contains(minecraftSources[i].getName()))
                {
                    FMLLog.finer("Skipping known library file %s", minecraftSources[i].getAbsolutePath());
                }
                else
                {
                    FMLLog.fine("Found a minecraft related file at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath());
                    candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.JAR, i==0, true));
                }
            }
            else if (minecraftSources[i].isDirectory())
            {
                FMLLog.fine("Found a minecraft related directory at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath());
                candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.DIR, i==0, true));
            }
        }
    }

}


问题


面经


文章

微信
公众号

扫码关注公众号