Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.spacechase0.minecraft.spelunkerdim.asm;
- import org.objectweb.asm.MethodVisitor;
- import static org.objectweb.asm.Opcodes.*;
- public class EnchantmentListSubInterceptor extends MethodVisitor
- {
- public EnchantmentListSubInterceptor( MethodVisitor mv )
- {
- super( ASM4, mv );
- }
- @Override
- public void visitInsn( int opcode )
- {
- if ( should && opcode == ARETURN )
- {
- visitVarInsn( ALOAD, 0 );
- visitMethodInsn( INVOKESTATIC, "com/spacechase0/minecraft/spelunkerdim/EnchantmentListInterceptor", "intercept", "(" + typeA + "L" + typeB + ";)V" );
- visitInsn( POP );
- visitVarInsn( ALOAD, 0 );
- should = false;
- did = true;
- }
- mv.visitInsn( opcode );
- }
- @Override
- public void visitLdcInsn( Object obj )
- {
- if ( obj instanceof String )
- {
- String str = ( String ) obj;
- if ( str.equals( "ench" ) )
- {
- should = true;
- }
- }
- mv.visitLdcInsn( obj );
- }
- public static boolean didChangeSomething()
- {
- return did;
- }
- public static void reset()
- {
- did = false;
- }
- private boolean should = false;
- public static String typeA;
- public static String typeB;
- private static boolean did = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement