Merge pull request #1279 from thatsIch/b-1264-render-crash-missing-rf-api
Fixes #1264: Does not crash on missing RF API
This commit is contained in:
@@ -20,6 +20,7 @@ package appeng.transformer;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
@@ -36,25 +37,21 @@ import appeng.core.AEConfig;
|
||||
|
||||
|
||||
@MCVersion( "1.7.10" )
|
||||
public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
public final class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
{
|
||||
|
||||
public final AppEngCore instance;
|
||||
|
||||
protected final ModMetadata md = new ModMetadata();
|
||||
private final ModMetadata metadata = new ModMetadata();
|
||||
|
||||
public AppEngCore()
|
||||
{
|
||||
this.instance = this;
|
||||
FMLRelaunchLog.info( "[AppEng] Core Init" );
|
||||
this.md.autogenerated = false;
|
||||
this.md.authorList.add( "AlgorithmX2" );
|
||||
this.md.credits = "AlgorithmX2";
|
||||
this.md.modId = this.getModId();
|
||||
this.md.version = this.getVersion();
|
||||
this.md.name = this.getName();
|
||||
this.md.url = "http://ae2.ae-mod.info";
|
||||
this.md.description = "Embedded Coremod for Applied Energistics 2";
|
||||
this.metadata.autogenerated = false;
|
||||
this.metadata.authorList.add( "AlgorithmX2" );
|
||||
this.metadata.credits = "AlgorithmX2";
|
||||
this.metadata.modId = this.getModId();
|
||||
this.metadata.version = this.getVersion();
|
||||
this.metadata.name = this.getName();
|
||||
this.metadata.url = "http://ae2.ae-mod.info";
|
||||
this.metadata.description = "Embedded Coremod for Applied Energistics 2";
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -74,6 +71,7 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
return "appeng.transformer.AppEngCore";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSetupClass()
|
||||
{
|
||||
@@ -95,7 +93,7 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
return this.md;
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.transformer.asm;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -34,13 +34,16 @@ import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.transformer.annotations.Integration;
|
||||
|
||||
|
||||
public class ASMIntegration implements IClassTransformer
|
||||
@Reflected
|
||||
public final class ASMIntegration implements IClassTransformer
|
||||
{
|
||||
@Reflected
|
||||
public ASMIntegration()
|
||||
{
|
||||
|
||||
@@ -64,6 +67,7 @@ public class ASMIntegration implements IClassTransformer
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public byte[] transform( String name, String transformedName, byte[] basicClass )
|
||||
{
|
||||
@@ -72,8 +76,6 @@ public class ASMIntegration implements IClassTransformer
|
||||
|
||||
if( transformedName.startsWith( "appeng." ) )
|
||||
{
|
||||
// log( "Found " + transformedName );
|
||||
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader( basicClass );
|
||||
classReader.accept( classNode, 0 );
|
||||
@@ -112,7 +114,7 @@ public class ASMIntegration implements IClassTransformer
|
||||
}
|
||||
else if( this.hasAnnotation( an, Integration.InterfaceList.class ) )
|
||||
{
|
||||
for( Object o : ( (List) an.values.get( 1 ) ) )
|
||||
for( Object o : ( (Iterable) an.values.get( 1 ) ) )
|
||||
{
|
||||
if( this.stripInterface( classNode, Integration.InterfaceList.class, (AnnotationNode) o ) )
|
||||
changed = true;
|
||||
@@ -145,12 +147,12 @@ public class ASMIntegration implements IClassTransformer
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean hasAnnotation( AnnotationNode ann, Class annotation )
|
||||
private boolean hasAnnotation( AnnotationNode ann, Class<?> annotation )
|
||||
{
|
||||
return ann.desc.equals( Type.getDescriptor( annotation ) );
|
||||
}
|
||||
|
||||
private boolean stripInterface( ClassNode classNode, Class class1, AnnotationNode an )
|
||||
private boolean stripInterface( ClassNode classNode, Class<?> class1, AnnotationNode an )
|
||||
{
|
||||
if( an.values.size() != 4 )
|
||||
throw new IllegalArgumentException( "Unable to handle Interface annotation on " + classNode.name );
|
||||
@@ -168,10 +170,9 @@ public class ASMIntegration implements IClassTransformer
|
||||
else if( an.values.get( 2 ).equals( "iname" ) )
|
||||
iName = (String) an.values.get( 3 );
|
||||
|
||||
IntegrationType type = IntegrationType.valueOf( iName );
|
||||
|
||||
if( iName != null && iFace != null )
|
||||
{
|
||||
final IntegrationType type = IntegrationType.valueOf( iName );
|
||||
if( !IntegrationRegistry.INSTANCE.isEnabled( type ) )
|
||||
{
|
||||
this.log( "Removing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is disabled." );
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.transformer.asm;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -39,26 +40,31 @@ import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
|
||||
public class ASMTweaker implements IClassTransformer
|
||||
|
||||
@Reflected
|
||||
public final class ASMTweaker implements IClassTransformer
|
||||
{
|
||||
private static final String[] EXCEPTIONS = new String[0];
|
||||
private final Multimap<String, PublicLine> privateToPublicMethods = HashMultimap.create();
|
||||
|
||||
final Multimap<String, publicLine> privateToPublicMethods = HashMultimap.create();
|
||||
|
||||
@Reflected
|
||||
public ASMTweaker()
|
||||
{
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new publicLine( "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V" ) );
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new publicLine( "a", "(Lzk;)V" ) );
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V" ) );
|
||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "a", "(Lzk;)V" ) );
|
||||
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "writeToNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "func_145841_b", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "b", "(Ldh;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "writeToNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "func_145841_b", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "b", "(Ldh;)V" ) );
|
||||
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "readFromNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "func_145839_a", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new publicLine( "a", "(Ldh;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "readFromNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "func_145839_a", "(Lnet/minecraft/nbt/NBTTagCompound;)V" ) );
|
||||
this.privateToPublicMethods.put( "appeng.tile.AEBaseTile", new PublicLine( "a", "(Ldh;)V" ) );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public byte[] transform( String name, String transformedName, byte[] basicClass )
|
||||
{
|
||||
@@ -73,9 +79,9 @@ public class ASMTweaker implements IClassTransformer
|
||||
ClassReader classReader = new ClassReader( basicClass );
|
||||
classReader.accept( classNode, 0 );
|
||||
|
||||
for( publicLine Set : this.privateToPublicMethods.get( transformedName ) )
|
||||
for( PublicLine set : this.privateToPublicMethods.get( transformedName ) )
|
||||
{
|
||||
this.makePublic( classNode, Set );
|
||||
this.makePublic( classNode, set );
|
||||
}
|
||||
|
||||
// CALL VIRTUAL!
|
||||
@@ -85,7 +91,7 @@ public class ASMTweaker implements IClassTransformer
|
||||
{
|
||||
if( mn.name.equals( "func_146977_a" ) || ( mn.name.equals( "a" ) && mn.desc.equals( "(Lzk;)V" ) ) )
|
||||
{
|
||||
MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, new String[0] );
|
||||
MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, EXCEPTIONS );
|
||||
newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 0 ) );
|
||||
newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 1 ) );
|
||||
newNode.instructions.add( new MethodInsnNode( Opcodes.INVOKESPECIAL, classNode.name, mn.name, mn.desc, false ) );
|
||||
@@ -132,7 +138,7 @@ public class ASMTweaker implements IClassTransformer
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
private void makePublic( ClassNode classNode, publicLine set )
|
||||
private void makePublic( ClassNode classNode, PublicLine set )
|
||||
{
|
||||
for( MethodNode mn : classNode.methods )
|
||||
{
|
||||
@@ -149,13 +155,12 @@ public class ASMTweaker implements IClassTransformer
|
||||
FMLRelaunchLog.log( "AE2-CORE", Level.INFO, string );
|
||||
}
|
||||
|
||||
class publicLine
|
||||
private static final class PublicLine
|
||||
{
|
||||
private final String name;
|
||||
private final String desc;
|
||||
|
||||
final String name;
|
||||
final String desc;
|
||||
|
||||
public publicLine( String name, String desc )
|
||||
public PublicLine( String name, String desc )
|
||||
{
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
|
||||
Reference in New Issue
Block a user