Yes, a JAR is just a zip with a different ending. But to answer your question, I would do the following:
If you just wanna add some code to a vanilla class, inject hooks (static function calls) or - if the "code" consists of just a few instructions - inject the code itself.
If you have to change 50% or more of a vanilla class's code, change the class's code itself and ship it with your release. Mojang will understand: "[...]Basically, mods (or plugins, or tools) are cool (you can distribute those)[...]"
Wouldnt distributing a mod using the zip method be against mojangs terms because it includes their class files?
There is no restriction to what you can do, as long as you are not packaging Mojang class files unedited. Any change to the class files, be it big or small, is acceptable. There has never been a problem with packaging edited Mojang classes. In fact, it used to be the only way to mod.
TBH you don't need a knowledge of JVM bytecode to use the ASM in Forge, you just need a knowledge of the stack, some small reflection knowledge, and a tad knowledge of how the ASM opcodes work......
Knowing how the bytecode works is non-relevant really...but it would be useful to do something extravagant.....
Don't know if OP is still active on this thread but THANK YOU for this tut!
I had a couple of issues getting FML to recognize my jar as a mod but adding
FMLCorePluginContainsFMLMod: true
to the manifest fixed it. Wish I could give a good explanation as to why, esp. since it seems that lots of other mods I looked at don't have that in their manifest, but tbh half of my modding is done flying by the seat of my pants and if it works I don't question it =P
So if I understand this right changing base vanilla minecraft code opens up new modding possibilities but it also affects the server comparability right? So by coding according to your tutorial I can avoid the sever compatability problems, eh? Supposedly?
Yes, and no. Server compatibility has never really been an issue, more it's compatibility with other mods. Instead of overwriting files, we can use this to just add what we need to the file. As a bonus, all our changes are reflected in other mods.
I am patching two classes, EntityPlayer and RenderLivingEntity (I know, they are large and I shouldn't replace the entire class, but for now its fine).
After I patch them, I get a very odd error. "creative.CreativeTabBlock.<init>(CreativeTabBlock.java:11)" which is simply this : super("SG: Blocks");
I can run the mod without patching the classes (but it crashes after it loads because the vars I added do not exist.). Which is normal. Once I patch, I cannot run MineCraft at all as it crashes upon startup.
Also the error is : java.lang.NoSuchMethodError: ww.<init>(Ljava/lang/String;)V
[code] public byte[] patchClassInJar(String name, byte[] byteCode, String ObfName, File location) {
try {
//open the jar as zip
ZipFile zip = new ZipFile(location);
//find the file inside the zip that is called te.class or net.minecraft.entity.monster.EntityCreeper.class
//replacing the . to / so it would look for net/minecraft/entity/monster/EntityCreeper.class
ZipEntry entry = zip.getEntry(name.replace('.', '/') + ".class");
if (entry == null)
{
System.out.println(name + " not found in " + location.getName());
}
else
{
InputStream zipInputStream = zip.getInputStream(entry);
int maxBytes = (int)entry.getSize();
byteCode = new byte[maxBytes];
int bytes = 0;
while(bytes < maxBytes) {
int inputLength = zipInputStream.read(byteCode, bytes, maxBytes - bytes);
if(inputLength <= 0)
throw new IOException();
bytes += inputLength;
}
zipInputStream.close();
}
zip.close();
}
catch (Exception e) {
throw new RuntimeException("Error overriding " + name + " from " + location.getName(), e);
}
//return the new bytes
return byteCode;
}[/code]
[code]public byte[] transform(String arg0, String arg1, byte[] arg2) {
//Check if the JVM is about to process the tc.class or the EntityCreeper.class
if (arg0.equals("bhb") || arg0.equals("net.minecraft.client.renderer.entity.RendererLivingEntity"))
{
System.out.println("********* INSIDE RENDERENTITYLIVING TRANSFORMER ABOUT TO PATCH: " + arg0);
arg2 = patchClassInJar(arg0, arg2, arg0, SGFMLLoadingPlugin.location);
}
if (arg0.equals("uf") || arg0.equals("net.minecraft.entity.player.EntityPlayer")) {
System.out.println("********* INSIDE EntityPlayer TRANSFORMER ABOUT TO PATCH: " + arg0);
arg2 = patchClassInJar(arg0, arg2, arg0, SGFMLLoadingPlugin.location);
}
return arg2;
}
[code]
@MCVersion(value = "1.6.4")
public class SGFMLLoadingPlugin implements cpw.mods.fml.relauncher.IFMLLoadingPlugin {
public static File location;
@Override
public String[] getLibraryRequestClass() {
// TODO Auto-generated method stub
return null;
}
@Override
public String[] getASMTransformerClass() {
//This will return the name of the class "mod.culegooner.CreeperBurnCore.CBClassTransformer"
return new String[]{ SGClassTransformer.class.getName() };
}
@Override
public String getModContainerClass() {
//This is the name of our dummy container "mod.culegooner.CreeperBurnCore.CBDummyContainer"
return SGDummyContainer.class.getName();
}
@Override
public String getSetupClass() {
// TODO Auto-generated method stub
return null;
}
@Override
public void injectData(Map<String, Object> data) {
//This will return the jar file of this mod CreeperBurnCore_dummy.jar"
location = (File) data.get("coremodLocation");
System.out.println("*** Transformer jar location location.getName: " +location.getName());
}
}[/code]
Can you explain how I can check if it has the new code. I am working on the ASM patch portion as well. Basically, all I want to do is add a local variable to EntityPlayer called FactionId. Then add that portion in the NBTRead and Write portion as well.
[/code]
Add an interface to the Entity class "public class Entity implements myInterface" and before you try to access your custom code check if the given entity implements this interface "if(myEntity instanceof myInterface)".
Your LoadingPlugin looks fine. Please post the whole code of your ClassTransformer.
I do not have a custom interface. I just am adding one line of code or so to EntityPLayer, which is already an active class.
Im still having this problem. I am no longer patching the entire class. I am just patching by ASM. I am still get a very odd error. I can take my mod, put it in a basic forge environment then run it. of course I get a crash because I am missing the variable from my coremod. Once I add the coremod, I get an error about CreativeTabs.
For running my core mod in development mode, i created a jar and put the MANIFEST in and linked it to my PLuginLoad. And when I am debugging I can see code being hit. So I know its patching right.
I tested without my mod and the coremod works fine. So I am really at a loss.
Hey, looking to asm mod net.minecraft.entity.player.EntityPlayer.java, having a hell of a time getting the bytecode plugin to work, any help would be greatly appreciated.
You managed to decompile and continue without me giving source code? O_O Bro, you are a god. Of course do whatever the [REDACTED] you want!!!! Good luck on it
Ok, so I used your code to replace a couple of classes (the whole files), everything recompiled fine, but when I ran the mod it crashed instantly:
---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.
Time: 25/01/14 14:54
Description: Initializing game
java.lang.NoClassDefFoundError: net/minecraft/client/renderer/ItemRenderer
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:486)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:808)
at net.minecraft.client.main.Main.main(SourceFile:101)
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:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.renderer.ItemRenderer
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
Caused by: java.lang.NullPointerException
at org.objectweb.asm.Type.getArgumentTypes(Unknown Source)
at org.objectweb.asm.commons.Remapper.mapMethodDesc(Unknown Source)
at org.objectweb.asm.commons.RemappingClassAdapter.visitMethod(Unknown Source)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer.transform(DeobfuscationTransformer.java:39)
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:274)
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:172)
... 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.func_71384_a(Minecraft.java:486)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:808)
at net.minecraft.client.main.Main.main(SourceFile:101)
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:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
-- System Details --
Details:
Minecraft Version: 1.6.4
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_13, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 68412728 bytes (65 MB) / 285671424 bytes (272 MB) up to 954466304 bytes (910 MB)
JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G
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.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 5 mods loaded, 5 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{6.4.45.953} [Forge Mod Loader] (minecraftforge-9.11.1.953.jar) Unloaded->Constructed->Pre-initialized
Forge{9.11.1.953} [Minecraft Forge] (minecraftforge-9.11.1.953.jar) Unloaded->Constructed->Pre-initialized
alpcore{§40.1} [AlpCore] (minecraft.jar) Unloaded->Constructed->Pre-initialized
enchantitemcolours{0.1} [Enchanted Item Colours] (EnchantColours_0.1.zip) Unloaded->Constructed->Pre-initialized
Launched Version: 1.6.4-Forge9.11.1.953
LWJGL: 2.9.0
OpenGL: GeForce GTX 650 Ti/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Pack: Default
Current Language: English (UK)
Profiler Position: N/A (disabled)
Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
Ok, so I used your code to replace a couple of classes (the whole files), everything recompiled fine, but when I ran the mod it crashed instantly:
---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.
Time: 25/01/14 14:54
Description: Initializing game
java.lang.NoClassDefFoundError: net/minecraft/client/renderer/ItemRenderer
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:486)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:808)
at net.minecraft.client.main.Main.main(SourceFile:101)
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:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.renderer.ItemRenderer
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
Caused by: java.lang.NullPointerException
at org.objectweb.asm.Type.getArgumentTypes(Unknown Source)
at org.objectweb.asm.commons.Remapper.mapMethodDesc(Unknown Source)
at org.objectweb.asm.commons.RemappingClassAdapter.visitMethod(Unknown Source)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer.transform(DeobfuscationTransformer.java:39)
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:274)
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:172)
... 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.func_71384_a(Minecraft.java:486)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:808)
at net.minecraft.client.main.Main.main(SourceFile:101)
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:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
-- System Details --
Details:
Minecraft Version: 1.6.4
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_13, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 68412728 bytes (65 MB) / 285671424 bytes (272 MB) up to 954466304 bytes (910 MB)
JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G
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.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 5 mods loaded, 5 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{6.4.45.953} [Forge Mod Loader] (minecraftforge-9.11.1.953.jar) Unloaded->Constructed->Pre-initialized
Forge{9.11.1.953} [Minecraft Forge] (minecraftforge-9.11.1.953.jar) Unloaded->Constructed->Pre-initialized
alpcore{§40.1} [AlpCore] (minecraft.jar) Unloaded->Constructed->Pre-initialized
enchantitemcolours{0.1} [Enchanted Item Colours] (EnchantColours_0.1.zip) Unloaded->Constructed->Pre-initialized
Launched Version: 1.6.4-Forge9.11.1.953
LWJGL: 2.9.0
OpenGL: GeForce GTX 650 Ti/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Pack: Default
Current Language: English (UK)
Profiler Position: N/A (disabled)
Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
I'm having an issue injecting a method. This works just fine as intended in eclipse, however when used in an obfuscated environment I get this error;
2013-10-22 19:29:49 [INFO] [STDOUT] INVOKEVIRTUAL opcode is -1 METHOD_INSN type is 15
2013-10-22 19:29:49 [INFO] [STDOUT] Patching Complete!
2013-10-22 19:29:49 [FINE] [ForgeModLoader] Runtime patching class net/minecraft/world/IBlockAccess (input size 367), found 1 patch
2013-10-22 19:29:49 [FINE] [ForgeModLoader] Successfully applied runtime patches for net/minecraft/world/IBlockAccess (new size 743)
2013-10-22 19:29:49 [SEVERE] [ForgeModLoader] Unable to launch
java.lang.reflect.InvocationTargetException
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:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft
at net.minecraft.client.main.Main.main(SourceFile:37)
... 6 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.Minecraft
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: avc
at org.objectweb.asm.ClassWriter.getCommonSuperClass(Unknown Source)
at org.objectweb.asm.ClassWriter.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at org.objectweb.asm.tree.ClassNode.accept(Unknown Source)
at tim.ClassTransformer.patchClassASM(ClassTransformer.java:183)
at tim.ClassTransformer.transform(ClassTransformer.java:27)
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:274)
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:172)
... 9 more
This is my code
Ignore the comments those are just leftover from the OP
public class ClassTransformer implements net.minecraft.launchwrapper.IClassTransformer {
@Override
public byte[] transform(String arg0, String arg1, byte[] arg2) {
if (arg0.equals("atv")) {
System.out.println("********* INSIDE OBFUSCATED EXPLOSION TRANSFORMER ABOUT TO PATCH: " + arg0);
return patchClassASM(arg0, arg2, true);
}
if (arg0.equals("net.minecraft.client.Minecraft")) {
System.out.println("********* INSIDE EXPLOSION TRANSFORMER ABOUT TO PATCH: " + arg0);
return patchClassASM(arg0, arg2, false);
}
return arg2;
}
public byte[] patchClassASM(String name, byte[] bytes, boolean obfuscated) {
String targetMethodName = "";
if(obfuscated == true)
targetMethodName ="k";
else
targetMethodName ="runTick";
//set up ASM class manipulation stuff. Consult the ASM docs for details
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
//Now we loop over all of the methods declared inside the Explosion class until we get to the targetMethodName "doExplosionB"
// find method to inject into
@SuppressWarnings("unchecked")
Iterator<MethodNode> methods = classNode.methods.iterator();
while(methods.hasNext())
{
MethodNode m = methods.next();
System.out.println("********* Method Name: "+m.name + " Desc:" + m.desc);
int fdiv_index = -1;
//Check if this is doExplosionB and it's method signature is (Z)V which means that it accepts a boolean (Z) and returns a void (V)
if ((m.name.equals(targetMethodName) && m.desc.equals("()V")))
{
System.out.println("********* Inside target method!");
// find interesting instructions in method, there is a single FDIV instruction we use as target
//System.out.println("m.instructions.size = " + m.instructions.size());
AbstractInsnNode currentNode = null;
AbstractInsnNode targetNode = null;
@SuppressWarnings("unchecked")
Iterator<AbstractInsnNode> iter = m.instructions.iterator();
int index = -1;
//Loop over the instruction set and find the instruction FDIV which does the division of 1/explosionSize
while (iter.hasNext() && index < 700)
{
index++;
currentNode = iter.next();
AbstractInsnNode nextNode = currentNode.getNext();
AbstractInsnNode thirdNode = nextNode.getNext();
System.out.println("********* index : " + index + " currentNode.getOpcode() = " + currentNode.getOpcode() + " Type: " + currentNode.getType());
if (currentNode.getType() == 15 && currentNode.getOpcode()==-1 && nextNode.getType() == 14 && thirdNode.getType() == 2)
{
targetNode = currentNode;
fdiv_index = index;
}
}
AbstractInsnNode addNode = m.instructions.get(fdiv_index);
AbstractInsnNode invVirt = m.instructions.get(fdiv_index );
if(invVirt.getOpcode() == -1)
{
if(invVirt.getType() == 15){
System.out.println("INVOKEVIRTUAL opcode is " + invVirt.getOpcode() + " METHOD_INSN type is " + invVirt.getType() );
}
}
InsnList toInject = new InsnList();
toInject.add(new MethodInsnNode(184, "tim/Base", "onKeyPressed", "()V"));
m.instructions.insertBefore(targetNode, toInject);
System.out.println("Patching Complete!");
break;
}
}
//ASM specific for cleaning up and returning the final bytes for JVM processing.
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
classNode.accept(writer);
return writer.toByteArray();
}
}
Greetings. Great tutorials culegooner, they've helped me a lot getting started!
I'm having trouble finding a field in an obfuscated environment. I'm trying to access the "mc" field (to call displayGuiScreen) from the GuiMainMenu's super (GuiScreen). Everything works as expected in eclipse.
I'm trying to inject the following (full code at bottom) into net.minecraft.client.GuiMainMenu:actionPerformed:
Greetings. Great tutorials culegooner, they've helped me a lot getting started!
I'm having trouble finding a field in an obfuscated environment. I'm trying to access the "mc" field (to call displayGuiScreen) from the GuiMainMenu's super (GuiScreen). Everything works as expected in eclipse.
I'm trying to inject the following (full code at bottom) into net.minecraft.client.GuiMainMenu:actionPerformed:
There is no restriction to what you can do, as long as you are not packaging Mojang class files unedited. Any change to the class files, be it big or small, is acceptable. There has never been a problem with packaging edited Mojang classes. In fact, it used to be the only way to mod.
Knowing how the bytecode works is non-relevant really...but it would be useful to do something extravagant.....
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI had a couple of issues getting FML to recognize my jar as a mod but adding to the manifest fixed it.
Wish I could give a good explanation as to why, esp. since it seems that lots of other mods I looked at don't have that in their manifest, but tbh half of my modding is done flying by the seat of my pants and if it works I don't question it =P
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYouTube | Twitter | Patreon
After I patch them, I get a very odd error. "creative.CreativeTabBlock.<init>(CreativeTabBlock.java:11)" which is simply this : super("SG: Blocks");
I can run the mod without patching the classes (but it crashes after it loads because the vars I added do not exist.). Which is normal. Once I patch, I cannot run MineCraft at all as it crashes upon startup.
Also the error is : java.lang.NoSuchMethodError: ww.<init>(Ljava/lang/String;)V
Any thoughts?
www.ScourgeCraft.net - 100 PvP Slots - Great world with lots to do!
[code]public byte[] transform(String arg0, String arg1, byte[] arg2) { //Check if the JVM is about to process the tc.class or the EntityCreeper.class if (arg0.equals("bhb") || arg0.equals("net.minecraft.client.renderer.entity.RendererLivingEntity")) { System.out.println("********* INSIDE RENDERENTITYLIVING TRANSFORMER ABOUT TO PATCH: " + arg0); arg2 = patchClassInJar(arg0, arg2, arg0, SGFMLLoadingPlugin.location); } if (arg0.equals("uf") || arg0.equals("net.minecraft.entity.player.EntityPlayer")) { System.out.println("********* INSIDE EntityPlayer TRANSFORMER ABOUT TO PATCH: " + arg0); arg2 = patchClassInJar(arg0, arg2, arg0, SGFMLLoadingPlugin.location); } return arg2; } [code] @MCVersion(value = "1.6.4") public class SGFMLLoadingPlugin implements cpw.mods.fml.relauncher.IFMLLoadingPlugin { public static File location; @Override public String[] getLibraryRequestClass() { // TODO Auto-generated method stub return null; } @Override public String[] getASMTransformerClass() { //This will return the name of the class "mod.culegooner.CreeperBurnCore.CBClassTransformer" return new String[]{ SGClassTransformer.class.getName() }; } @Override public String getModContainerClass() { //This is the name of our dummy container "mod.culegooner.CreeperBurnCore.CBDummyContainer" return SGDummyContainer.class.getName(); } @Override public String getSetupClass() { // TODO Auto-generated method stub return null; } @Override public void injectData(Map<String, Object> data) { //This will return the jar file of this mod CreeperBurnCore_dummy.jar" location = (File) data.get("coremodLocation"); System.out.println("*** Transformer jar location location.getName: " +location.getName()); } }[/code]
Can you explain how I can check if it has the new code. I am working on the ASM patch portion as well. Basically, all I want to do is add a local variable to EntityPlayer called FactionId. Then add that portion in the NBTRead and Write portion as well.
[/code]
www.ScourgeCraft.net - 100 PvP Slots - Great world with lots to do!
I do not have a custom interface. I just am adding one line of code or so to EntityPLayer, which is already an active class.
www.ScourgeCraft.net - 100 PvP Slots - Great world with lots to do!
For running my core mod in development mode, i created a jar and put the MANIFEST in and linked it to my PLuginLoad. And when I am debugging I can see code being hit. So I know its patching right.
I tested without my mod and the coremod works fine. So I am really at a loss.
www.ScourgeCraft.net - 100 PvP Slots - Great world with lots to do!
www.ScourgeCraft.net - 100 PvP Slots - Great world with lots to do!
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
www.ScourgeCraft.net - 100 PvP Slots - Great world with lots to do!
-
View User Profile
-
View Posts
-
Send Message
Curse Premium-tlf
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumPatreon
---- Minecraft Crash Report ---- // Quite honestly, I wouldn't worry myself about that. Time: 25/01/14 14:54 Description: Initializing game java.lang.NoClassDefFoundError: net/minecraft/client/renderer/ItemRenderer at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:486) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:808) at net.minecraft.client.main.Main.main(SourceFile:101) 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:131) at net.minecraft.launchwrapper.Launch.main(Launch.java:27) Caused by: java.lang.ClassNotFoundException: net.minecraft.client.renderer.ItemRenderer at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 9 more Caused by: java.lang.NullPointerException at org.objectweb.asm.Type.getArgumentTypes(Unknown Source) at org.objectweb.asm.commons.Remapper.mapMethodDesc(Unknown Source) at org.objectweb.asm.commons.RemappingClassAdapter.visitMethod(Unknown Source) at org.objectweb.asm.ClassReader.b(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer.transform(DeobfuscationTransformer.java:39) at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:274) at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:172) ... 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.func_71384_a(Minecraft.java:486) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:808) at net.minecraft.client.main.Main.main(SourceFile:101) 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:131) at net.minecraft.launchwrapper.Launch.main(Launch.java:27) -- System Details -- Details: Minecraft Version: 1.6.4 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_13, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 68412728 bytes (65 MB) / 285671424 bytes (272 MB) up to 954466304 bytes (910 MB) JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G 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.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 5 mods loaded, 5 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{6.4.45.953} [Forge Mod Loader] (minecraftforge-9.11.1.953.jar) Unloaded->Constructed->Pre-initialized Forge{9.11.1.953} [Minecraft Forge] (minecraftforge-9.11.1.953.jar) Unloaded->Constructed->Pre-initialized alpcore{§40.1} [AlpCore] (minecraft.jar) Unloaded->Constructed->Pre-initialized enchantitemcolours{0.1} [Enchanted Item Colours] (EnchantColours_0.1.zip) Unloaded->Constructed->Pre-initialized Launched Version: 1.6.4-Forge9.11.1.953 LWJGL: 2.9.0 OpenGL: GeForce GTX 650 Ti/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Pack: Default Current Language: English (UK) Profiler Position: N/A (disabled) Vec3 Pool Size: ~~ERROR~~ NullPointerException: nullIf I helped you, please click the green up arrow.
-
View User Profile
-
View Posts
-
Send Message
Curse Premium-tlf
I'm having trouble finding a field in an obfuscated environment. I'm trying to access the "mc" field (to call displayGuiScreen) from the GuiMainMenu's super (GuiScreen). Everything works as expected in eclipse.
I'm trying to inject the following (full code at bottom) into net.minecraft.client.GuiMainMenu:actionPerformed:
but I keep getting
When I try to iterate through the fields in the class
Iterator<FieldNode> fields = classNode.fields.iterator();
while(fields.hasNext()) {
FieldNode f = fields.next();
System.out.println("Field:"+f.name+" : "+f.desc);
}
Loader and DummyContainer are as per these examples. My complete transformer code is
Edit: Spoilered a code block
-
View User Profile
-
View Posts
-
Send Message
Curse Premium-tlf
Perfect, that worked! One small task down, still the more annoying dev to go
Kremnari
-
View User Profile
-
View Posts
-
Send Message
Curse Premium-tlf
How do .patch file work?
For example, what do these mean:
@@ -13,8 +18,13 @@