Add Core Mod to Enable AE Slots ( Temporary? )
This commit is contained in:
parent
f0c4c8c8a9
commit
74ce7156c4
4 changed files with 245 additions and 4 deletions
|
@ -434,7 +434,8 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
try
|
||||
{
|
||||
// drawSlotInventory
|
||||
// super.func_146977_a( s );
|
||||
// super.func_146977_a( s );r
|
||||
GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
@ -451,9 +452,7 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// private void func_146977_a(Slot p_146977_1_)
|
||||
protected void drawSlotInventory(Slot s)
|
||||
public void func_146977_a(Slot s)
|
||||
{
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
|
|
125
transformer/AppEngASMTransformer.java
Normal file
125
transformer/AppEngASMTransformer.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package appeng.transformer;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public class AppEngASMTransformer implements IClassTransformer
|
||||
{
|
||||
|
||||
Multimap<String, String> publicShit = HashMultimap.create();
|
||||
|
||||
public AppEngASMTransformer() {
|
||||
publicShit.put( "net.minecraft.client.gui.inventory.GuiContainer", "func_146977_a" );
|
||||
publicShit.put( "bcd", "a" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass)
|
||||
{
|
||||
if ( publicShit.containsKey( name ) || publicShit.containsKey( transformedName ) )
|
||||
{
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader( basicClass );
|
||||
classReader.accept( classNode, 0 );
|
||||
|
||||
for (String Set : publicShit.get( name ))
|
||||
{
|
||||
makePublic( classNode, Set );
|
||||
}
|
||||
|
||||
for (String Set : publicShit.get( transformedName ))
|
||||
{
|
||||
makePublic( classNode, Set );
|
||||
}
|
||||
|
||||
// CALL VIRUAL!
|
||||
if ( transformedName.equals( "net.minecraft.client.gui.inventory.GuiContainer" ) )
|
||||
{
|
||||
for (MethodNode mn : classNode.methods)
|
||||
{
|
||||
if ( mn.name.equals( "func_146977_a" ) )
|
||||
{
|
||||
MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, new String[0] );
|
||||
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 ) );
|
||||
newNode.instructions.add( new InsnNode( Opcodes.RETURN ) );
|
||||
classNode.methods.add( newNode );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (MethodNode mn : classNode.methods)
|
||||
{
|
||||
if ( mn.name.equals( "drawScreen" ) )
|
||||
{
|
||||
Iterator<AbstractInsnNode> i = mn.instructions.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
AbstractInsnNode in = i.next();
|
||||
if ( in.getOpcode() == Opcodes.INVOKESPECIAL )
|
||||
{
|
||||
MethodInsnNode n = (MethodInsnNode) in;
|
||||
if ( n.name.equals( "func_146977_a" ) )
|
||||
{
|
||||
mn.instructions.insertBefore( n, new MethodInsnNode( Opcodes.INVOKEVIRTUAL, n.owner, n.name, n.desc ) );
|
||||
mn.instructions.remove( in );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClassWriter writer = new ClassWriter( ClassWriter.COMPUTE_MAXS );
|
||||
classNode.accept( writer );
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
private void makePublic(ClassNode classNode, String set)
|
||||
{
|
||||
|
||||
for (MethodNode mn : classNode.methods)
|
||||
{
|
||||
if ( mn.name.equals( set ) )
|
||||
{
|
||||
mn.access = getFixedAccess( mn.access );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (FieldNode mn : classNode.fields)
|
||||
{
|
||||
if ( mn.name.equals( set ) )
|
||||
{
|
||||
mn.access = getFixedAccess( mn.access );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int getFixedAccess(int access)
|
||||
{
|
||||
return Opcodes.ACC_PUBLIC;
|
||||
}
|
||||
}
|
14
transformer/AppEngATTransformer.java
Normal file
14
transformer/AppEngATTransformer.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package appeng.transformer;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
public class AppEngATTransformer implements IClassTransformer
|
||||
{
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass)
|
||||
{
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
}
|
103
transformer/AppEngCore.java
Normal file
103
transformer/AppEngCore.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
package appeng.transformer;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
|
||||
@MCVersion("1.7.2")
|
||||
public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
{
|
||||
|
||||
protected final ModMetadata md = new ModMetadata();
|
||||
|
||||
@EventHandler
|
||||
public void load(FMLInitializationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public AppEngCore() {
|
||||
FMLRelaunchLog.info( "[AppEng] Core Init" );
|
||||
md.autogenerated = true;
|
||||
md.credits = "AlgorithmX2";
|
||||
md.modId = getModId();
|
||||
md.version = getVersion();
|
||||
md.name = getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass()
|
||||
{
|
||||
return new String[] { "appeng.transformer.AppEngASMTransformer" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass()
|
||||
{
|
||||
return "appeng.transformer.AppEngCore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModId()
|
||||
{
|
||||
return "AppliedEnergistics2-Core";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "AppliedEnergistics2 Core";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
return AEConfig.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayVersion()
|
||||
{
|
||||
return getVersion();
|
||||
}
|
||||
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
return md;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue