-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/reobf/proghatches/main/asm/ASMCallbacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package reobf.proghatches.main.asm; | ||
|
||
import gregtech.api.metatileentity.CommonMetaTileEntity; | ||
import gregtech.api.metatileentity.CoverableTileEntity; | ||
import gregtech.api.metatileentity.MetaTileEntity; | ||
import reobf.proghatches.oc.IActualEnvironment; | ||
|
||
public class ASMCallbacks { | ||
public static boolean checkIsRealEnvironment(Object o){ | ||
|
||
if(o instanceof CommonMetaTileEntity){ | ||
|
||
CommonMetaTileEntity mte=(CommonMetaTileEntity) o; | ||
if(mte.getMetaTileEntity() instanceof IActualEnvironment){ | ||
|
||
|
||
return o instanceof li.cil.oc.api.network.Environment; | ||
}else{return false;} | ||
|
||
} | ||
|
||
|
||
return o instanceof li.cil.oc.api.network.Environment; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/reobf/proghatches/main/asm/MFUTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package reobf.proghatches.main.asm; | ||
|
||
import net.minecraft.launchwrapper.IClassTransformer; | ||
|
||
import reobf.proghatches.main.asm.repack.objectwebasm.ClassReader; | ||
import reobf.proghatches.main.asm.repack.objectwebasm.ClassWriter; | ||
import reobf.proghatches.main.asm.repack.objectwebasm.MethodVisitor; | ||
import reobf.proghatches.main.asm.repack.objectwebasm.Opcodes; | ||
import reobf.proghatches.main.asm.repack.objectwebasm.tree.ClassNode; | ||
import reobf.proghatches.main.asm.repack.objectwebasm.tree.MethodNode; | ||
|
||
public class MFUTransformer implements IClassTransformer {boolean done; | ||
|
||
@Override | ||
public byte[] transform(String name, String transformedName, byte[] basicClass) { | ||
if(!done) | ||
if(name.equals("li.cil.oc.server.component.UpgradeMF")){ | ||
done=true; | ||
ClassReader classReader = new ClassReader(basicClass); | ||
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS|ClassWriter.COMPUTE_FRAMES); | ||
ClassNode n=new ClassNode(Opcodes.ASM5){ | ||
|
||
@Override | ||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, | ||
String[] exceptions) { | ||
if(name.equals("updateBoundState")){ | ||
MethodNode mn = new TheNode(access, name, desc, signature,exceptions){ | ||
|
||
|
||
|
||
|
||
|
||
}; | ||
methods.add(mn); | ||
return mn; | ||
|
||
} | ||
return super.visitMethod(access, name, desc, signature, exceptions); | ||
} | ||
}; | ||
|
||
classReader.accept(n, ClassReader.EXPAND_FRAMES); | ||
n.accept(classWriter); | ||
|
||
|
||
return classWriter.toByteArray(); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
return basicClass; | ||
} | ||
static class TheNode extends MethodNode{ | ||
|
||
public TheNode(int access, String name, String desc, String signature, String[] exceptions) { | ||
super(Opcodes.ASM5,access, name, desc, signature, exceptions); | ||
} | ||
@Override | ||
public void visitTypeInsn(int opcode, String type) { | ||
if(opcode==Opcodes.INSTANCEOF&&type.equals("li/cil/oc/api/network/Environment")){ | ||
|
||
super.visitMethodInsn(Opcodes.INVOKESTATIC, "reobf/proghatches/main/asm/ASMCallbacks", "checkIsRealEnvironment", "(Ljava/lang/Object;)Z", false); | ||
return; | ||
|
||
} | ||
super.visitTypeInsn(opcode, type); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package reobf.proghatches.oc; | ||
|
||
public interface IActualEnvironment { | ||
|
||
} |