mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 00:07:45 +00:00
Capture interfaces when scanning classes and preload implementations of ICrashReportDetail.
This commit is contained in:
1 parent
a97b4c4db7
commit
a1a67e7654
4 files changed
+45
-115
No files matched your search
@@ -59,119 +59,6 @@ public class MinecraftForge
|
||||
|
||||
OreDictionary.getOreName(0);
|
||||
|
||||
//Force these classes to be defined, Should prevent derp error hiding.
|
||||
@SuppressWarnings("unused")
|
||||
CrashReport fake = new CrashReport("ThisIsFake", new Exception("Not real"));
|
||||
//Lets init World's crash report inner classes to prevent them from hiding errors.
|
||||
String[] handlers = {
|
||||
"net.minecraft.world.World$1",
|
||||
"net.minecraft.world.World$2",
|
||||
"net.minecraft.world.World$3",
|
||||
"net.minecraft.world.World$4",
|
||||
"net.minecraft.world.chunk.Chunk$1",
|
||||
"net.minecraft.world.chunk.Chunk$2",
|
||||
"net.minecraft.world.chunk.Chunk$3",
|
||||
"net.minecraft.command.server.CommandBlockLogic$1",
|
||||
"net.minecraft.command.server.CommandBlockLogic$2",
|
||||
"net.minecraft.crash.CrashReportCategory$1",
|
||||
"net.minecraft.crash.CrashReportCategory$2",
|
||||
"net.minecraft.crash.CrashReportCategory$3",
|
||||
"net.minecraft.crash.CrashReportCategory$4",
|
||||
"net.minecraft.crash.CrashReportCategory$5",
|
||||
"net.minecraft.crash.CrashReportCategory$Entry",
|
||||
"net.minecraft.entity.Entity$1",
|
||||
"net.minecraft.entity.Entity$2",
|
||||
"net.minecraft.entity.Entity$3",
|
||||
"net.minecraft.entity.Entity$4",
|
||||
"net.minecraft.entity.EntityTracker$1",
|
||||
"net.minecraft.world.gen.layer.GenLayer$1",
|
||||
"net.minecraft.world.gen.layer.GenLayer$2",
|
||||
"net.minecraft.entity.player.InventoryPlayer$1",
|
||||
"net.minecraft.world.gen.structure.MapGenStructure$1",
|
||||
"net.minecraft.world.gen.structure.MapGenStructure$2",
|
||||
"net.minecraft.world.gen.structure.MapGenStructure$3",
|
||||
"net.minecraft.server.MinecraftServer$3",
|
||||
"net.minecraft.server.MinecraftServer$4",
|
||||
"net.minecraft.server.MinecraftServer$5",
|
||||
"net.minecraft.nbt.NBTTagCompound$1",
|
||||
"net.minecraft.nbt.NBTTagCompound$2",
|
||||
"net.minecraft.network.NetHandlerPlayServer$2",
|
||||
"net.minecraft.network.NetworkSystem$3",
|
||||
"net.minecraft.tileentity.TileEntity$1",
|
||||
"net.minecraft.tileentity.TileEntity$2",
|
||||
"net.minecraft.tileentity.TileEntity$3",
|
||||
"net.minecraft.world.storage.WorldInfo$1",
|
||||
"net.minecraft.world.storage.WorldInfo$2",
|
||||
"net.minecraft.world.storage.WorldInfo$3",
|
||||
"net.minecraft.world.storage.WorldInfo$4",
|
||||
"net.minecraft.world.storage.WorldInfo$5",
|
||||
"net.minecraft.world.storage.WorldInfo$6",
|
||||
"net.minecraft.world.storage.WorldInfo$7",
|
||||
"net.minecraft.world.storage.WorldInfo$8",
|
||||
"net.minecraft.world.storage.WorldInfo$9"
|
||||
};
|
||||
String[] client = {
|
||||
"net.minecraft.client.Minecraft$3",
|
||||
"net.minecraft.client.Minecraft$4",
|
||||
"net.minecraft.client.Minecraft$5",
|
||||
"net.minecraft.client.Minecraft$6",
|
||||
"net.minecraft.client.Minecraft$7",
|
||||
"net.minecraft.client.Minecraft$8",
|
||||
"net.minecraft.client.Minecraft$9",
|
||||
"net.minecraft.client.Minecraft$10",
|
||||
"net.minecraft.client.Minecraft$11",
|
||||
"net.minecraft.client.Minecraft$12",
|
||||
"net.minecraft.client.Minecraft$13",
|
||||
"net.minecraft.client.Minecraft$14",
|
||||
"net.minecraft.client.Minecraft$15",
|
||||
"net.minecraft.client.multiplayer.WorldClient$1",
|
||||
"net.minecraft.client.multiplayer.WorldClient$2",
|
||||
"net.minecraft.client.multiplayer.WorldClient$3",
|
||||
"net.minecraft.client.multiplayer.WorldClient$4",
|
||||
"net.minecraft.client.particle,EffectRenderer$1",
|
||||
"net.minecraft.client.particle,EffectRenderer$2",
|
||||
"net.minecraft.client.particle,EffectRenderer$3",
|
||||
"net.minecraft.client.particle,EffectRenderer$4",
|
||||
"net.minecraft.client.renderer.EntityRenderer$1",
|
||||
"net.minecraft.client.renderer.EntityRenderer$2",
|
||||
"net.minecraft.client.renderer.EntityRenderer$3",
|
||||
"net.minecraft.server.integrated.IntegratedServer$1",
|
||||
"net.minecraft.server.integrated.IntegratedServer$2",
|
||||
"net.minecraft.client.renderer.RenderGlobal$1",
|
||||
"net.minecraft.client.renderer.entity.RenderItem$1",
|
||||
"net.minecraft.client.renderer.entity.RenderItem$2",
|
||||
"net.minecraft.client.renderer.entity.RenderItem$3",
|
||||
"net.minecraft.client.renderer.entity.RenderItem$4",
|
||||
"net.minecraft.client.renderer.texture.TextureAtlasSprite$1",
|
||||
"net.minecraft.client.renderer.texture.TextureManager$1",
|
||||
"net.minecraft.client.renderer.texture.TextureMap$1",
|
||||
"net.minecraft.client.renderer.texture.TextureMap$2",
|
||||
"net.minecraft.client.renderer.texture.TextureMap$3"
|
||||
};
|
||||
String[] server = {
|
||||
"net.minecraft.server.dedicated.DedicatedServer$3",
|
||||
"net.minecraft.server.dedicated.DedicatedServer$4"
|
||||
};
|
||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
|
||||
handlers = ObjectArrays.concat(handlers, client, String.class);
|
||||
else
|
||||
handlers = ObjectArrays.concat(handlers, server, String.class);
|
||||
|
||||
//FMLLog.info("Preloading CrashReport classes", ForgeVersion.getVersion());
|
||||
for (String s : handlers)
|
||||
{
|
||||
//FMLLog.info("\t" + s);
|
||||
try
|
||||
{
|
||||
Class<?> cls = Class.forName(s, false, MinecraftForge.class.getClassLoader());
|
||||
if (cls != null && !Callable.class.isAssignableFrom(cls))
|
||||
{
|
||||
//FMLLog.info("\t% s is not a instance of callable!", s);
|
||||
}
|
||||
}
|
||||
catch (Exception e){}
|
||||
}
|
||||
|
||||
UsernameCache.load();
|
||||
// Load before all the mods, so MC owns the MC fluids
|
||||
FluidRegistry.validateFluidRegistry();
|
||||
|
||||
@@ -26,11 +26,14 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.ICrashReportDetail;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
import net.minecraftforge.fml.common.ModContainer.Disableable;
|
||||
import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import net.minecraftforge.fml.common.discovery.ModDiscoverer;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.fml.common.event.FMLLoadEvent;
|
||||
@@ -518,6 +521,7 @@ public class Loader
|
||||
}
|
||||
}
|
||||
}
|
||||
preloadCrashClasses();
|
||||
modController.transition(LoaderState.CONSTRUCTING, false);
|
||||
modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, discoverer.getASMTable(), reverseDependencies);
|
||||
|
||||
@@ -1114,4 +1118,33 @@ public class Loader
|
||||
{
|
||||
return modController != null ? modController.getState() : LoaderState.NOINIT;
|
||||
}
|
||||
|
||||
|
||||
private void preloadCrashClasses()
|
||||
{
|
||||
//For all the normal CrashReport classes to be defined. We're in MC's classloader so this should all be fine
|
||||
new CrashReport("ThisIsFake", new Exception("Not real"));
|
||||
|
||||
FMLLog.log(Level.DEBUG, "Preloading CrashReport Classes");
|
||||
//Find all ICrashReportDetail's handlers and preload them.
|
||||
List<String> classes = Lists.newArrayList();
|
||||
for (ASMData asm : discoverer.getASMTable().getAll(ICrashReportDetail.class.getName().replace('.', '/')))
|
||||
{
|
||||
classes.add(asm.getClassName());
|
||||
}
|
||||
for (ASMData asm : discoverer.getASMTable().getAll(ICrashCallable.class.getName().replace('.', '/')))
|
||||
{
|
||||
classes.add(asm.getClassName());
|
||||
}
|
||||
Collections.sort(classes); //Sort it because I like pretty output ;)
|
||||
for (String name : classes)
|
||||
{
|
||||
FMLLog.log(Level.DEBUG, "\t" + name);
|
||||
try
|
||||
{
|
||||
Class<?> cls = Class.forName(name, false, getClass().getClassLoader());
|
||||
}
|
||||
catch (Exception e){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.LoaderException;
|
||||
@@ -30,6 +31,7 @@ import org.objectweb.asm.Type;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public class ASMModParser
|
||||
{
|
||||
@@ -38,6 +40,7 @@ public class ASMModParser
|
||||
private int classVersion;
|
||||
private Type asmSuperType;
|
||||
private LinkedList<ModAnnotation> annotations = Lists.newLinkedList();
|
||||
private Set<String> interfaces = Sets.newHashSet();
|
||||
private String baseModProperties;
|
||||
|
||||
static enum AnnotationType
|
||||
@@ -59,11 +62,13 @@ public class ASMModParser
|
||||
}
|
||||
}
|
||||
|
||||
public void beginNewTypeName(String typeQName, int classVersion, String superClassQName)
|
||||
public void beginNewTypeName(String typeQName, int classVersion, String superClassQName, String[] interfaces)
|
||||
{
|
||||
this.asmType = Type.getObjectType(typeQName);
|
||||
this.classVersion = classVersion;
|
||||
this.asmSuperType = !Strings.isNullOrEmpty(superClassQName) ? Type.getObjectType(superClassQName) : null;
|
||||
for (String intf : interfaces)
|
||||
this.interfaces.add(intf);
|
||||
}
|
||||
|
||||
public void startClassAnnotation(String annotationName)
|
||||
@@ -146,6 +151,11 @@ public class ASMModParser
|
||||
{
|
||||
table.addASMData(candidate, ma.asmType.getClassName(), this.asmType.getClassName(), ma.member, ma.values);
|
||||
}
|
||||
|
||||
for (String intf : interfaces)
|
||||
{
|
||||
table.addASMData(candidate, intf, this.asmType.getClassName(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void addAnnotationArray(String name)
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ModClassVisitor extends ClassVisitor
|
||||
@Override
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
|
||||
{
|
||||
discoverer.beginNewTypeName(name, version, superName);
|
||||
discoverer.beginNewTypeName(name, version, superName, interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user