From b8f72c678bfa4d66a9c7cb75b97f5a7dbc7d6d21 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 17 Mar 2013 23:40:12 -0400 Subject: [PATCH] Support simple mc version test in coremods, only effective through jar loading. Also, log some more data about the environment. --- .../cpw/mods/fml/relauncher/FMLRelauncher.java | 7 +++++-- .../mods/fml/relauncher/IFMLLoadingPlugin.java | 16 +++++++++++++++- .../fml/relauncher/RelaunchLibraryManager.java | 12 ++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/fml/common/cpw/mods/fml/relauncher/FMLRelauncher.java b/fml/common/cpw/mods/fml/relauncher/FMLRelauncher.java index 3fe3fe7b5..599706a91 100644 --- a/fml/common/cpw/mods/fml/relauncher/FMLRelauncher.java +++ b/fml/common/cpw/mods/fml/relauncher/FMLRelauncher.java @@ -132,8 +132,8 @@ public class FMLRelauncher private Class setupNewClientHome(File minecraftHome) { Class client = ReflectionHelper.getClass(classLoader, "net.minecraft.client.Minecraft"); - ReflectionHelper.setPrivateValue(client, null, minecraftHome, - "field_" + "71463_am" /*Separate that so that MCP's updatenames does not replace it*/, + ReflectionHelper.setPrivateValue(client, null, minecraftHome, + "field_" + "71463_am" /*Separate that so that MCP's updatenames does not replace it*/, "an", "minecraftDir"); return client; } @@ -163,6 +163,9 @@ public class FMLRelauncher FMLRelaunchLog.minecraftHome = minecraftHome; FMLRelaunchLog.info("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s loading", FMLInjectionData.major, FMLInjectionData.minor, FMLInjectionData.rev, FMLInjectionData.build, FMLInjectionData.mccversion, FMLInjectionData.mcpversion); + FMLRelaunchLog.info("Java is %s, version %s, running on %s:%s:%s, installed at %s", System.getProperty("java.vm.name"), System.getProperty("java.version"), System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version"), System.getProperty("java.home")); + FMLRelaunchLog.fine("Java classpath at launch is %s", System.getProperty("java.class.path")); + FMLRelaunchLog.fine("Java library path at launch is %s", System.getProperty("java.library.path")); try { diff --git a/fml/common/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java b/fml/common/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java index a389da18b..3561ebf51 100644 --- a/fml/common/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java +++ b/fml/common/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java @@ -5,7 +5,7 @@ * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * + * * Contributors: * cpw - implementation */ @@ -87,4 +87,18 @@ public interface IFMLLoadingPlugin { public String[] value() default ""; } + + /** + * Use this to target a specific minecraft version for your coremod. It will refuse to load with an error if + * minecraft is not this exact version. + * + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface MCVersion + { + public String value() default ""; + } } diff --git a/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java index 47abc7b13..58e8017a1 100644 --- a/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java +++ b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java @@ -38,6 +38,7 @@ import java.util.jar.JarFile; import java.util.logging.Level; import cpw.mods.fml.common.CertificateHelper; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions; public class RelaunchLibraryManager @@ -406,6 +407,17 @@ public class RelaunchLibraryManager downloadMonitor.updateProgressString("Loading coremod %s", coreMod.getName()); classLoader.addTransformerExclusion(fmlCorePlugin); Class coreModClass = Class.forName(fmlCorePlugin, true, classLoader); + MCVersion requiredMCVersion = coreModClass.getAnnotation(IFMLLoadingPlugin.MCVersion.class); + String version = requiredMCVersion.value(); + if (!"".equals(version) && !FMLInjectionData.mccversion.equals(version)) + { + FMLRelaunchLog.log(Level.SEVERE, "The coremod %s is requesting minecraft version %s and minecraft is %s. It will be ignored.", fmlCorePlugin, version, FMLInjectionData.mccversion); + continue; + } + else if (!"".equals(version)) + { + FMLRelaunchLog.log(Level.FINE, "The coremod %s requested minecraft version %s and minecraft is %s. It will be loaded.", fmlCorePlugin, version, FMLInjectionData.mccversion); + } TransformerExclusions trExclusions = coreModClass.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class); if (trExclusions!=null) {