Attempt early initialization of Minecraft Forge

This commit is contained in:
Christian 2012-06-07 19:25:49 -04:00
parent 33fc5228ce
commit 00a9cd4a5f
3 changed files with 47 additions and 40 deletions

View File

@ -161,37 +161,9 @@ public class FMLClientHandler implements IFMLSidedHandler
public void onPreLoad(Minecraft minecraft) public void onPreLoad(Minecraft minecraft)
{ {
/* try
{
Class.forName("BaseModMp", false, getClass().getClassLoader());
Minecraft.field_6301_A.severe(""
+ "Forge Mod Loader has detected that this server has an ModLoaderMP installed alongside Forge Mod Loader.\n"
+ "This will cause a serious problem with compatibility. To protect your worlds, this minecraft server will now shutdown.\n"
+ "You should follow the installation instructions of either Minecraft Forge of Forge Mod Loader and NOT install ModLoaderMP \n"
+ "into the minecraft_server.jar file "
+ "before this server will be allowed to start up.\n\nFailure to do so will simply result in more startup failures.\n\n"
+ "The authors of Minecraft Forge and Forge Mod Loader strongly suggest you talk to your mod's authors and get them to\nupdate their "
+ "requirements. ModLoaderMP is not compatible with Minecraft Forge on the server and they will need to update their mod\n"
+ "for Minecraft Forge and other server compatibility, unless they are Minecraft Forge mods, in which case they already\n"
+ "don't need ModLoaderMP and the mod author simply has failed to update his requirements and should be informed appropriately.\n\n"
+ "The authors of Forge Mod Loader would like to be compatible with ModLoaderMP but it is closed source and owned by SDK.\n"
+ "SDK, the author of ModLoaderMP, has a standing invitation to submit compatibility patches \n"
+ "to the open source community project that is Forge Mod Loader so that this incompatibility doesn't last. \n"
+ "Users who wish to enjoy mods of both types are "
+ "encouraged to request of SDK that he submit a\ncompatibility patch to the Forge Mod Loader project at \n"
+ "http://github.com/cpw/FML.\nPosting on the minecraft forums at\nhttp://www.minecraftforum.net/topic/86765- (the MLMP thread)\n"
+ "may encourage him in this effort. However, I ask that your requests be polite.\n"
+ "Now, the server has to shutdown so you can reinstall your minecraft_server.jar\nproperly, until such time as we can work together.");
throw new RuntimeException(
"This FML based server has detected an installation of ModLoaderMP alongside. This will cause serious compatibility issues, so the server will now shut down.");
}
catch (ClassNotFoundException e)
{
// We're safe. continue
}*/
client = minecraft; client = minecraft;
ReflectionHelper.detectObfuscation(World.class); ReflectionHelper.detectObfuscation(World.class);
FMLCommonHandler.instance().registerSidedDelegate(this); FMLCommonHandler.instance().beginLoading(this);
FMLRegistry.registerRegistry(new ClientRegistry()); FMLRegistry.registerRegistry(new ClientRegistry());
try try
{ {
@ -227,7 +199,6 @@ public class FMLClientHandler implements IFMLSidedHandler
*/ */
public void onLoadComplete() public void onLoadComplete()
{ {
client.field_6315_n.func_1065_b();
Loader.instance().initializeMods(); Loader.instance().initializeMods();
for (ModContainer mod : Loader.getModList()) { for (ModContainer mod : Loader.getModList()) {
mod.gatherRenderers(RenderManager.field_1233_a.getRendererList()); mod.gatherRenderers(RenderManager.field_1233_a.getRendererList());

View File

@ -17,6 +17,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -85,9 +86,12 @@ public class FMLCommonHandler
* We register our delegate here * We register our delegate here
* @param handler * @param handler
*/ */
public void registerSidedDelegate(IFMLSidedHandler handler) public void beginLoading(IFMLSidedHandler handler)
{ {
sidedDelegate = handler; sidedDelegate = handler;
getFMLLogger().info("Attempting early MinecraftForge initialization");
callForgeMethod("initialize");
getFMLLogger().info("Completed early MinecraftForge initialization");
} }
public void tickStart(EnumSet<TickType> ticks, Object ... data) public void tickStart(EnumSet<TickType> ticks, Object ... data)
@ -399,6 +403,42 @@ public class FMLCommonHandler
throw new RuntimeException(exception); throw new RuntimeException(exception);
} }
private Class<?> forge;
private boolean noForge;
private Class<?> findMinecraftForge()
{
if (forge==null && !noForge)
{
try {
forge = Class.forName("forge.MinecraftForge");
} catch (Exception ex) {
try {
forge = Class.forName("net.minecraft.src.forge.MinecraftForge");
} catch (Exception ex2) {
// Ignore- forge isn't loaded
noForge = true;
}
}
}
return forge;
}
private Object callForgeMethod(String method)
{
if (noForge)
return null;
try
{
return findMinecraftForge().getMethod(method).invoke(null);
}
catch (Exception e)
{
// No Forge installation
return null;
}
}
/** /**
* @param string * @param string
* @return * @return
@ -408,14 +448,10 @@ public class FMLCommonHandler
ArrayList<String> brandings=new ArrayList<String>(); ArrayList<String> brandings=new ArrayList<String>();
brandings.add(mcVersion); brandings.add(mcVersion);
brandings.add(Loader.instance().getFMLVersionString()); brandings.add(Loader.instance().getFMLVersionString());
try { String forgeVersion = (String)callForgeMethod("getVersionString");
brandings.add((String)Class.forName("forge.MinecraftForge").getMethod("getVersionString").invoke(null)); if (forgeVersion != null)
} catch (Exception ex) { {
try { brandings.add(forgeVersion);
brandings.add((String)Class.forName("net.minecraft.src.forge.MinecraftForge").getMethod("getVersionString").invoke(null));
} catch (Exception ex2) {
// Ignore- forge isn't loaded
}
} }
brandings.addAll(sidedDelegate.getAdditionalBrandingInformation()); brandings.addAll(sidedDelegate.getAdditionalBrandingInformation());
try { try {

View File

@ -134,7 +134,7 @@ public class FMLServerHandler implements IFMLSidedHandler
} }
server = minecraftServer; server = minecraftServer;
ReflectionHelper.detectObfuscation(World.class); ReflectionHelper.detectObfuscation(World.class);
FMLCommonHandler.instance().registerSidedDelegate(this); FMLCommonHandler.instance().beginLoading(this);
FMLRegistry.registerRegistry(new ServerRegistry()); FMLRegistry.registerRegistry(new ServerRegistry());
Loader.instance().loadMods(); Loader.instance().loadMods();
} }