Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if ((m.name.equals(targetMethod3Name) && m.desc
- .equals("(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;"))) {
- System.out
- .println("********* [ImageBufferDowload] Inside target3 method!");
- AbstractInsnNode currentNode = null;
- AbstractInsnNode targetNode = null;
- AbstractInsnNode targetNode2 = null;
- @SuppressWarnings("unchecked")
- Iterator<AbstractInsnNode> iter = m.instructions.iterator();
- int index = -1;
- // On boucle jusqu'a trouver le premier bipush (16)
- while (iter.hasNext()) {
- index++;
- currentNode = iter.next();
- System.out.println(currentNode.getOpcode());
- // Found it! save the index location of instruction FDIV and
- // the node for this instruction
- if (currentNode.getOpcode() == BIPUSH) {
- targetNode = currentNode;
- targetNode2 = targetNode == null ? null : currentNode;
- bipush_index = index;
- if (targetNode != null && targetNode2 != null)
- break;
- }
- }
- // on créer les variables à supprimer pour la hauteur
- AbstractInsnNode remNode3 = m.instructions
- .get(bipush_index + 3);
- AbstractInsnNode remNode4 = m.instructions
- .get(bipush_index + 4);
- // on les supprime
- m.instructions.remove(remNode3);
- m.instructions.remove(remNode4);
- // on créer les instruction à insérer
- InsnList toInject2 = new InsnList();
- toInject2.add(new VarInsnNode(ALOAD, 1));
- toInject2.add(new MethodInsnNode(INVOKEVIRTUAL,
- "java/awt/image/BufferedImage", "getHeight", "()I"));
- toInject2.add(new FieldInsnNode(PUTFIELD,
- "net/minecraft/client/renderer/ImageBufferDownload",
- "imageHeight", "I"));
- // on les insère
- m.instructions.insert(targetNode2, toInject2);
- // on créer les variables à supprimer pour la largeur
- AbstractInsnNode remNode1 = m.instructions.get(bipush_index);
- AbstractInsnNode remNode2 = m.instructions
- .get(bipush_index + 1);
- // on les supprime
- m.instructions.remove(remNode1);
- m.instructions.remove(remNode2);
- // on créer les instruction à insérer
- InsnList toInject = new InsnList();
- toInject.add(new VarInsnNode(ALOAD, 1));
- toInject.add(new MethodInsnNode(INVOKEVIRTUAL,
- "java/awt/image/BufferedImage", "getWidth", "()I"));
- toInject.add(new FieldInsnNode(PUTFIELD,
- "net/minecraft/client/renderer/ImageBufferDownload",
- "imageWidth", "I"));
- // on les insère
- m.instructions.insert(targetNode, toInject);
- System.out
- .println("[ImageBufferDownload] Patching Method3 Complete!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement