Support simple mc version test in coremods, only effective through

jar loading.
Also, log some more data about the environment.
This commit is contained in:
Christian 2013-03-17 23:40:12 -04:00
parent ed17b11a76
commit b8f72c678b
3 changed files with 32 additions and 3 deletions

View file

@ -132,8 +132,8 @@ public class FMLRelauncher
private Class<? super Object> setupNewClientHome(File minecraftHome)
{
Class<? super Object> 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
{

View file

@ -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 "";
}
}

View file

@ -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)
{