Jump to content

Modifying the Main Menu


Recommended Posts

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:

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);



		ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);


		bytes = writer.toByteArray();


	return bytes;



The error is coming from here:

		ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);


		bytes = writer.toByteArray();


Any ideas?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.