    001    package cpw.mods.fml.common.asm;
    002
    003    import org.objectweb.asm.ClassReader;
    004    import org.objectweb.asm.ClassWriter;
    005    import org.objectweb.asm.Opcodes;
    006    import org.objectweb.asm.Type;
    007    import org.objectweb.asm.tree.ClassNode;
    008
    009    import cpw.mods.fml.common.registry.BlockProxy;
    010    import cpw.mods.fml.relauncher.IClassTransformer;
    011
    012    public class ASMTransformer implements IClassTransformer
    013    {
    014        @Override
    015        public byte[] transform(String name, byte[] bytes)
    016        {
    017            if ("net.minecraft.src.Block".equals(name))
    018            {
    019                ClassReader cr = new ClassReader(bytes);
    020                ClassNode cn = new ClassNode(Opcodes.ASM4);
    021                cr.accept(cn, ClassReader.EXPAND_FRAMES);
    022                cn.interfaces.add(Type.getInternalName(BlockProxy.class));
    023                ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    024                cn.accept(cw);
    025                return cw.toByteArray();
    026            }
    027
    028            return bytes;
    029        }
    030
    031    }