Posted November 23, 201311 yr I've already experimented with ASM and the sort, and I can modify access values with ASM. I can also replace a class fairly easily. What I would like to know is to easily in 1.6.4 change a method / insert code into a vanilla method, specifically the main menu. Could anyone help me on the matter? EDIT: I have gotten most of it done. But now I'm getting a NullPointerException when trying to get the ClassNode to accept a ClassWriter. Here is the error: Caused by: java.lang.NullPointerException at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:340) at net.winneonsword.WCClient.asm.WCClassTransformer.transform(WCClassTransformer.java:119) at net.winneonsword.WCClient.asm.WCClassTransformer.transform(WCClassTransformer.java:64) at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:274) at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:172) ... 9 more And here is the transform method: @Override public byte[] transform(String x, String y, byte[] z){ byte[] bytes = z; PatchInfo patch = this.getPatchInfo(y); if (patch != null){ bytes = this.transform(patch, bytes); } return z; } private byte[] transform(PatchInfo patch, byte[] z){ boolean patched = false; byte[] bytes = z; ClassNode node = new ClassNode(); ClassReader reader = new ClassReader(bytes); reader.accept(node, 0); WCLog.fine("Patching Class: %s", new Object[] { patch.target }); HashMap<MethodNode, MethodNode> replace = new HashMap(); for (MethodNode target : node.methods){ for (MethodInfo method : patch.methods){ if ((method.name.equals(method.name) || method.name.equals(method.mappedName)) && (method.desc.equals(method.desc) || method.desc.equals(method.mappedDesc))){ MethodNode replacement = this.getReplacementMethod(patch, method); replace.put(target, replacement); WCLog.fine("Successfully Patched: %s at %s", new Object[] { method.name, method.desc }); patched = true; } } } if (patched){ for (MethodNode method : replace.keySet()){ MethodNode replacement = replace.get(method); node.methods.remove(method); node.methods.add(replacement); } ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); node.accept(writer); bytes = writer.toByteArray(); } return bytes; } The error is coming from here: ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); node.accept(writer); bytes = writer.toByteArray(); Any ideas?
November 23, 201311 yr I am going to recommend checking out the MainMenu API for some help. It is outdated, but the src is available. http://www.minecraftforum.net/topic/1757119-151apiforge-main-menu-api-v11-have-your-own-main-menu-no-base-class-edits-jukebox-player/ Hope it helps
November 23, 201311 yr Author I've done some things and almost have it done. But I'm getting an NPE I do not know how to fix. The info is in the first post.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.