Fix up fubar in worldprovider. Add in obfuscation detection. Capture the exception that crashes minecraft in the log file.

This commit is contained in:
Christian Weeks 2012-05-14 18:21:35 -04:00
parent 6b23024f11
commit bc23e7a657
6 changed files with 39 additions and 9 deletions

View File

@ -71,6 +71,7 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModContainer.TickType;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
@ -162,6 +163,7 @@ public class FMLClientHandler implements IFMLSidedHandler
// We're safe. continue
}*/
client = minecraft;
ReflectionHelper.detectObfuscation(World.class);
FMLCommonHandler.instance().registerSidedDelegate(this);
CommonRegistry.registerRegistry(new ClientRegistry());
Loader.instance().loadMods();

View File

@ -13,6 +13,7 @@
package cpw.mods.fml.common;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* Some reflection helper code.
*
@ -21,6 +22,8 @@ import java.lang.reflect.Field;
*/
public class ReflectionHelper
{
public static boolean obfuscation;
@SuppressWarnings("unchecked")
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, E instance, int fieldIndex)
{
@ -49,8 +52,10 @@ public class ReflectionHelper
}
catch (Exception e)
{
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem getting field %s from %s", fieldName, classToAccess.getName()));
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
if ((fieldName.length() > 3 && !obfuscation) || (fieldName.length() <= 3 && obfuscation)) {
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem getting field %s from %s", fieldName, classToAccess.getName()));
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
}
throw new RuntimeException(e);
}
}
@ -81,10 +86,20 @@ public class ReflectionHelper
}
catch (Exception e)
{
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem setting field %s from %s", fieldName, classToAccess.getName()));
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
if ((fieldName.length() > 3 && !obfuscation) || (fieldName.length() <= 3 && obfuscation)) {
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem setting field %s from %s", fieldName, classToAccess.getName()));
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
}
throw new RuntimeException(e);
}
}
/**
*
*/
public static void detectObfuscation(Class<?> clazz)
{
obfuscation=!clazz.getSimpleName().equals("World");
}
}

View File

@ -352,7 +352,7 @@ public class ModLoaderModContainer implements ModContainer
@Override
public String getName()
{
return mod != null ? mod.getName() : getSource().getName();
return mod != null ? mod.getName() : modClazz.getSimpleName();
}
public static ModContainer findContainerFor(BaseMod mod)
@ -555,7 +555,7 @@ public class ModLoaderModContainer implements ModContainer
public String toString()
{
return modSource.getName();
return modClazz.getSimpleName();
}
@Override

View File

@ -1,15 +1,26 @@
--- ../src-base/minecraft/net/minecraft/src/PanelCrashReport.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/PanelCrashReport.java 0000-00-00 00:00:00.000000000 -0000
@@ -12,6 +12,8 @@
@@ -9,13 +9,19 @@
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.logging.Level;
+
import org.lwjgl.Sys;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.Loader;
+
public class PanelCrashReport extends Panel
{
public PanelCrashReport(UnexpectedThrowable p_i634_1_)
@@ -43,7 +45,7 @@
{
+ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, "A critical error has occurred.", p_i634_1_.field_6514_b);
this.setBackground(new Color(3028036));
this.setLayout(new BorderLayout());
StringWriter var2 = new StringWriter();
@@ -43,7 +49,7 @@
var5 = var5 + "\n";
var5 = var5 + var3;

View File

@ -12,7 +12,7 @@
- {
- this.field_4215_b = new WorldChunkManager(this.field_4216_a);
- }
+ this.field_46067_b.getChunkManager(field_4216_a);
+ this.field_4215_b=this.field_46067_b.getChunkManager(field_4216_a);
}
public IChunkProvider func_4094_c()

View File

@ -48,6 +48,7 @@ import cpw.mods.fml.common.IFMLSidedHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
/**
@ -123,6 +124,7 @@ public class FMLServerHandler implements IFMLSidedHandler
// We're safe. continue
}
server = minecraftServer;
ReflectionHelper.detectObfuscation(World.class);
FMLCommonHandler.instance().registerSidedDelegate(this);
CommonRegistry.registerRegistry(new ServerRegistry());
Loader.instance().loadMods();