This might be your problem.
Also, where are you getting '436' from?
huh, I don't remember where I got that but I know it's not right and I don't know how to get the correct index location of the PUTFIELD Opcode. I probably should have mentioned this in the first post but what I don't understand is how in the tutorial when he tests for the FDIV, how will it find the correct operation? What if in the method there are multiple divisions? I assume that's why you get the index but what if another mod injects first? Won't the index location change?
First off, please put all code in '[cde]' tags. It makes it much easier to read. Also, We will be able to help much more if you give us an error log.
Ahh my bad, I fixed my first post. And here is the crash report.
---- Minecraft Crash Report ----
// My bad.
Time: 8/15/13 12:37 AM
Description: Initializing game
java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiMultiplayer
at net.minecraft.client.Minecraft.startGame(Minecraft.java:516)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:796)
at net.minecraft.client.main.Main.main(Main.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)
at net.minecraft.launchwrapper.Launch.main(Launch.java:18)
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.gui.GuiMultiplayer
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 3
at java.lang.String.charAt(Unknown Source)
at org.objectweb.asm.Type.getArgumentsAndReturnSizes(Type.java:413)
at org.objectweb.asm.Frame.pop(Frame.java:732)
at org.objectweb.asm.Frame.execute(Frame.java:1198)
at org.objectweb.asm.MethodWriter.visitMethodInsn(MethodWriter.java:818)
at org.objectweb.asm.tree.MethodInsnNode.accept(MethodInsnNode.java:102)
at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162)
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:585)
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:515)
at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:340)
at mod.ian25.AltSwitcher.ASClassTransformer.patchClassASM(ASClassTransformer.java:129)
at mod.ian25.AltSwitcher.ASClassTransformer.transform(ASClassTransformer.java:33)
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:267)
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:165)
... 11 more
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at net.minecraft.client.Minecraft.startGame(Minecraft.java:516)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:796)
at net.minecraft.client.main.Main.main(Main.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)
at net.minecraft.launchwrapper.Launch.main(Launch.java:18)
-- System Details --
Details:
Minecraft Version: 1.6.2
Operating System: Windows 8 (amd64) version 6.2
Java Version: 1.7.0_25, Oracle Corporation
Java VM Version: Java HotSpotâ„¢ 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 799616088 bytes (762 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Suspicious classes: FML and Forge are installed
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v8.04 FML v6.2.35.804 Minecraft Forge 9.10.0.804 4 mods loaded, 3 mods active
mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available
FML{6.2.35.804} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available
Forge{9.10.0.804} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available
AltSwitcher{0.0} [AltSwitcher] (coremods) Unloaded->Disabled
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: AMD Radeon HD 6770M GL version 4.2.11931 Compatibility Profile Context, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Pack: Default
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
Alright, I've been struggling with this for a while now but I hope you guys can help.
Since all of the alternate account switcher mods that I have found are outdated/inactive I wanted to make my own. I have successfully made one that lets me switch accounts by adding a button to GuiMultiplayer. It works great and I'm almost satisfied except I had to modify two base classes. GuiMultiplayer to add the button and the GuiButton action to open my login gui. And Minecraft to make the session public.
Since I want to make this mod compatible with nearly all other mods I want to not have to modify those base classes.
Now on to what I need help with.
I followed the tutorial and I got my mod to stop explosions from destroying items. After, I changed the class to look for the GuiMultiplayer class and the initGuiControls method. It finds them no problem but I cannot for the life of me figure out how to add the button.
ClassTransformer
package mod.ian25.AltSwitcher;
import java.util.Iterator;
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.FieldInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
public class ASClassTransformer implements IClassTransformer {
@Override
public byte[] transform(String arg0, String arg1, byte[] arg2) {
if(arg0.equals("avk")) {
System.out.println("**Inside OBFUSCATED GuiMultiplayer... About to patch: " + arg0);
return patchClassASM(arg0, arg2, true);
}
if(arg0.equals("net.minecraft.client.gui.GuiMultiplayer")) {
System.out.println("**Inside NONOBFUSCATED GuiMultiplayer... About to patch: " + arg0);
return patchClassASM(arg0, arg2, false);
}
return arg2;
}
public byte[] patchClassASM(String name, byte[] bytes, boolean obfuscated) {
String targetMethodName = "";
if(obfuscated) {
targetMethodName = "g";
} else if(!obfuscated) {
targetMethodName = "initGuiControls";
}
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
Iterator<MethodNode> methods = classNode.methods.iterator();
while(methods.hasNext())
{
MethodNode m = methods.next();
int target_index = -1;
if ((m.name.equals(targetMethodName) && m.desc.equals("()V")))
{
System.out.println("**Inside target method: " + m.name + "**");
AbstractInsnNode currentNode = null;
AbstractInsnNode targetNode = null;
@SuppressWarnings("unchecked")
Iterator<AbstractInsnNode> iter = m.instructions.iterator();
int index = -1;
while (iter.hasNext())
{
index++;
currentNode = iter.next();
System.out.println("** Index : " + index + " currentNode.getOpcode() = " + currentNode.getOpcode());
if (currentNode.getOpcode() == Opcodes.PUTFIELD)
{
targetNode = currentNode;
target_index = index;
}
}
System.out.println("********* target_index should be (436?) -> " + target_index);
if (targetNode == null)
{
System.out.println("Did not find all necessary target nodes! ABANDON CLASS!");
return bytes;
}
if (target_index == -1)
{
System.out.println("Did not find all necessary target nodes! ABANDON CLASS!");
return bytes;
}
//Code to add the button will go here
System.out.println("Patching Complete!");
break;
}
}
System.out.println("Debug1");
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
System.out.println("Debug2");
classNode.accept(writer);
System.out.println("Debug3");
return writer.toByteArray();
}
}
GuiMultiplayer- initGuiControls method (The last line is what I'm trying to add)
Now, although I'm having some trouble with the Eclipse Bytecode plugin I was able to get the bytecode for the method I want.
(I only included a little bit of the method)
Line 13 is what I want to add. Now, this bytecode barley makes sense to me but I can see some method to the madness and I was able to come up with this.
Is it possible to use enchantment table slots? I mean when I put the item in the slot on table GUI it should always enchant at level 30 (or the highest value).
0
huh, I don't remember where I got that but I know it's not right and I don't know how to get the correct index location of the PUTFIELD Opcode. I probably should have mentioned this in the first post but what I don't understand is how in the tutorial when he tests for the FDIV, how will it find the correct operation? What if in the method there are multiple divisions? I assume that's why you get the index but what if another mod injects first? Won't the index location change?
0
Sure thing,
0
Ahh my bad, I fixed my first post. And here is the crash report.
0
Since all of the alternate account switcher mods that I have found are outdated/inactive I wanted to make my own. I have successfully made one that lets me switch accounts by adding a button to GuiMultiplayer. It works great and I'm almost satisfied except I had to modify two base classes. GuiMultiplayer to add the button and the GuiButton action to open my login gui. And Minecraft to make the session public.
Since I want to make this mod compatible with nearly all other mods I want to not have to modify those base classes.
Now on to what I need help with.
I followed the tutorial and I got my mod to stop explosions from destroying items. After, I changed the class to look for the GuiMultiplayer class and the initGuiControls method. It finds them no problem but I cannot for the life of me figure out how to add the button.
ClassTransformer
GuiMultiplayer- initGuiControls method (The last line is what I'm trying to add)
Now, although I'm having some trouble with the Eclipse Bytecode plugin I was able to get the bytecode for the method I want.
(I only included a little bit of the method)
Line 13 is what I want to add. Now, this bytecode barley makes sense to me but I can see some method to the madness and I was able to come up with this.
I'm definitely doing something wrong because it crashes when I add that in.
My final ClassTransformer looks like this.
I hope this made some sense to one of you guys and you'll be able to point out what I did wrong.
Thanks in advance!
0
0