name = name.replace('.', '/');
ClassNode cn = new ClassNode(ASM4);
cr.accept(cn, ClassReader.EXPAND_FRAMES);
final String sig = "(Lnet/minecraft/world/storage/ISaveHandler;Ljava/lang/String;Lnet/minecraft/world/WorldProvider;Lnet/minecraft/world/WorldSettings;Lnet/minecraft/profiler/Profiler;)V";
FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
MethodNode addTileEntity = null, addTileEntities = null, setTileEntity = null, updateEntities = null;
boolean found = false;
for (MethodNode m : cn.methods) {
if ("<init>".equals(m.name)) {
if (sig.equals(remapper.mapMethodDesc(m.desc)))
found = true;
LabelNode a = new LabelNode(new Label());
AbstractInsnNode n = m.instructions.getFirst();
while (n.getOpcode() != INVOKESPECIAL ||
!((MethodInsnNode)n).name.equals("<init>")) n = n.getNext();
m.instructions.insert(n, n = a);
m.instructions.insert(n, n = new LineNumberNode(-15000, a));
m.instructions.insert(n, n = new VarInsnNode(ALOAD, 0));
m.instructions.insert(n, n = new TypeInsnNode(NEW, "cofh/lib/util/LinkedHashList"));
m.instructions.insert(n, n = new InsnNode(DUP));
m.instructions.insert(n, n = new MethodInsnNode(INVOKESPECIAL, "cofh/lib/util/LinkedHashList", "<init>", "()V", false));
m.instructions.insert(n, n = new FieldInsnNode(PUTFIELD, "net/minecraft/world/World", "cofh_recentTiles", "Lcofh/lib/util/LinkedHashList;"));
} else if ("addTileEntity".equals(m.name) && "(Lnet/minecraft/tileentity/TileEntity;)V".equals(remapper.mapMethodDesc(m.desc))) {
addTileEntity = m;
} else if (names[4].equals(remapper.mapMethodName(name, m.name, m.desc)) && "(Ljava/util/Collection;)V".equals(m.desc)) {
addTileEntities = m;
} else if (names[5].equals(remapper.mapMethodName(name, m.name, m.desc)) && "(IIILnet/minecraft/tileentity/TileEntity;)V".equals(remapper.mapMethodDesc(m.desc))) {
setTileEntity = m;
} else if (names[6].equals(remapper.mapMethodName(name, m.name, m.desc)) && "()V".equals(remapper.mapMethodDesc(m.desc))) {
updateEntities = m;
}
}
cn.fields.add(new FieldNode(ACC_PRIVATE, "cofh_recentTiles", "Lcofh/lib/util/LinkedHashList;", null, null));
if (addTileEntity != null) {
LabelNode a = new LabelNode(new Label());
AbstractInsnNode n;
addTileEntity.instructions.insert(n = a);
addTileEntity.instructions.insert(n, n = new LineNumberNode(-15001, a));
addTileEntity.instructions.insert(n, n = new VarInsnNode(ALOAD, 0));
addTileEntity.instructions.insert(n, n = new FieldInsnNode(GETFIELD, "net/minecraft/world/World", "cofh_recentTiles", "Lcofh/lib/util/LinkedHashList;"));
addTileEntity.instructions.insert(n, n = new VarInsnNode(ALOAD, 1));
addTileEntity.instructions.insert(n, n = new MethodInsnNode(INVOKEVIRTUAL, "cofh/lib/util/LinkedHashList", "push", "(Ljava/lang/Object;)Z", false));
addTileEntity.instructions.insert(n, n = new InsnNode(POP));
}
if (setTileEntity != null) {
LabelNode a = new LabelNode(new Label());
AbstractInsnNode n = setTileEntity.instructions.getLast();
while (n.getOpcode() != RETURN) n = n.getPrevious();
n = n.getPrevious();
setTileEntity.instructions.insert(n = a);
setTileEntity.instructions.insert(n, n = new LineNumberNode(-15002, a));
setTileEntity.instructions.insert(n, n = new VarInsnNode(ALOAD, 0));
setTileEntity.instructions.insert(n, n = new FieldInsnNode(GETFIELD, "net/minecraft/world/World", "cofh_recentTiles", "Lcofh/lib/util/LinkedHashList;"));
setTileEntity.instructions.insert(n, n = new VarInsnNode(ALOAD, 4));
setTileEntity.instructions.insert(n, n = new MethodInsnNode(INVOKEVIRTUAL, "cofh/lib/util/LinkedHashList", "push", "(Ljava/lang/Object;)Z", false));
setTileEntity.instructions.insert(n, n = new InsnNode(POP));
}
if (addTileEntities != null) {
LabelNode a = new LabelNode(new Label());
AbstractInsnNode n = addTileEntities.instructions.getFirst();
for (;;) {
while (n.getOpcode() != CHECKCAST) n = n.getNext();
if (remapper.mapType(((TypeInsnNode)n).desc).equals("net/minecraft/tileentity/TileEntity"))
break;
}
addTileEntities.instructions.insert(n, n = a);
addTileEntities.instructions.insert(n, n = new LineNumberNode(-15003, a));
addTileEntities.instructions.insert(n, n = new InsnNode(DUP));