package net.blay09.mods.defaultkeys.coremod;

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.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;

import java.util.Iterator;

public class DefaultOptionsClassTransformer implements IClassTransformer {

    public static final String OBF_CLASS = "bao";
    public static final String MCP_CLASS = "net.minecraft.client.Minecraft";
    public static final String OBF_METHOD = "func_71384_a";
    public static final String MCP_METHOD = "startGame";
    private static final String METHOD_DESC = "()V";

    @Override
    public byte[] transform(String className, String transformedClassName, byte[] bytes) {
        String methodName;
        if(className.equals(OBF_CLASS)) {
            methodName = OBF_METHOD;
        } else if(className.equals(MCP_CLASS)) {
            methodName = MCP_METHOD;
        } else {
            return bytes;
        }
        ClassNode classNode = new ClassNode();
        ClassReader classReader = new ClassReader(bytes);
        classReader.accept(classNode, 0);
        Iterator<MethodNode> methods = classNode.methods.iterator();
        while(methods.hasNext()) {
            MethodNode method = methods.next();
            if(method.name.equals(methodName) && method.desc.equals(METHOD_DESC)) {
                AbstractInsnNode node = method.instructions.get(0);
                method.instructions.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "net/blay09/mods/defaultkeys/DefaultKeys", "preStartGame", "()V", false));
            }
        }
        ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        classNode.accept(writer);
        return writer.toByteArray();
    }

}

@@ -385,36 +385,8 @@
 e;%0A%0A
-import java.util.Iterator;%0A%0A
 publ
@@ -1264,17 +1264,13 @@
     
-Iterator%3C
+for (
 Meth
@@ -1279,19 +1279,17 @@
 Node
-%3E
  method
-s =
+ :
  cla
@@ -1306,103 +1306,11 @@
 hods
-.iterator();%0A        while(methods.hasNext()) %7B%0A            MethodNode method = methods.next();
+) %7B
 %0A   
@@ -1320,16 +1320,17 @@
       if
+ 
 (method.
@@ -1630,16 +1630,39 @@
 alse));%0A
+                break;%0A
         

Add missing break statement.