Mods can add mod specific crash information to the crash report now

Forge needs to implement MinecraftForge.getCrashCallable
This commit is contained in:
Christian 2012-08-21 18:48:12 -04:00
parent a17396eca5
commit 63e8249040
4 changed files with 53 additions and 5 deletions

View File

@ -20,6 +20,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.CrashReport;
import net.minecraft.src.DedicatedServer;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityPlayer;
@ -64,12 +65,18 @@ public class FMLCommonHandler
private List<IScheduledTickHandler> scheduledClientTicks = Lists.newArrayList();
private List<IScheduledTickHandler> scheduledServerTicks = Lists.newArrayList();
private Class<?> forge;
private boolean noForge;
private List<String> brandings;
private List<ICrashCallable> crashCallables = Lists.newArrayList(Loader.instance().getCallableCrashInformation());
public void beginLoading(IFMLSidedHandler handler)
{
sidedDelegate = handler;
FMLLog.info("Attempting early MinecraftForge initialization");
callForgeMethod("initialize");
callForgeMethod("registerCrashCallable");
FMLLog.info("Completed early MinecraftForge initialization");
}
@ -172,9 +179,6 @@ public class FMLCommonHandler
}
private Class<?> forge;
private boolean noForge;
private List<String> brandings;
private Class<?> findMinecraftForge()
{
if (forge==null && !noForge)
@ -363,4 +367,17 @@ public class FMLCommonHandler
Side side = player instanceof EntityPlayerMP ? Side.SERVER : Side.CLIENT;
tickEnd(EnumSet.of(TickType.PLAYER), side, player);
}
public void registerCrashCallable(ICrashCallable callable)
{
crashCallables.add(callable);
}
public void enhanceCrashReport(CrashReport crashReport)
{
for (ICrashCallable call: crashCallables)
{
crashReport.func_71500_a(call.getLabel(), call);
}
}
}

View File

@ -0,0 +1,8 @@
package cpw.mods.fml.common;
import java.util.concurrent.Callable;
public interface ICrashCallable extends Callable<String>
{
String getLabel();
}

View File

@ -595,14 +595,20 @@ public class Loader
FMLLog.info("Forge Mod Loader has successfully loaded %d mod%s", mods.size(), mods.size()==1 ? "" : "s");
}
public Callable getCallableCrashInformation()
public ICrashCallable getCallableCrashInformation()
{
return new Callable<String>() {
return new ICrashCallable() {
@Override
public String call() throws Exception
{
return getCrashInformation();
}
@Override
public String getLabel()
{
return "FML";
}
};
}

View File

@ -0,0 +1,17 @@
--- ../src-base/common/net/minecraft/src/CrashReport.java
+++ ../src-work/common/net/minecraft/src/CrashReport.java
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import java.io.File;
@@ -39,6 +40,7 @@
this.func_71500_a("Java VM Version", new CallableJavaInfo2(this));
this.func_71500_a("Memory", new CallableMemoryInfo(this));
this.func_71500_a("JVM Flags", new CallableJVMFlags(this));
+ FMLCommonHandler.instance().enhanceCrashReport(this);
}
public void func_71500_a(String p_71500_1_, Callable p_71500_2_)