Jump to content

[1.6.4] Problem using class transformer


SackCastellon

Recommended Posts

I've followed this tutorial

 

This is the error:

 

Client> 2013-10-07 21:27:54 [iNFO] [ForgeModLoader] Forge Mod Loader version 6.4.20.916 for Minecraft 1.6.4 loading
Client> 2013-10-07 21:27:54 [iNFO] [ForgeModLoader] Java is Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_25, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7
Client> 2013-10-07 21:27:54 [WARNING] [ForgeModLoader] The coremod codechicken.core.launch.CodeChickenCorePlugin does not have a MCVersion annotation, it may cause issues with this version of Minecraft
Client> 2013-10-07 21:27:55 [WARNING] [ForgeModLoader] The coremod codechicken.nei.asm.NEICorePlugin does not have a MCVersion annotation, it may cause issues with this version of Minecraft
Client> 2013-10-07 21:27:55 [WARNING] [ForgeModLoader] The coremod SackCastellon.stainedsand.asm.FMLLoadingPlugin does not have a MCVersion annotation, it may cause issues with this version of Minecraft
Client> 2013-10-07 21:27:55 [iNFO] [sTDOUT] Loaded 40 rules from AccessTransformer config file fml_at.cfg
Client> 2013-10-07 21:27:56 [iNFO] [sTDOUT] Loaded 109 rules from AccessTransformer config file forge_at.cfg
Client> 2013-10-07 21:27:56 [iNFO] [sTDOUT] Loaded 40 rules from AccessTransformer config file fml_at.cfg
Client> 2013-10-07 21:27:59 [iNFO] [ForgeModLoader] Found valid fingerprint for Minecraft Forge. Certificate fingerprint e3c3d50c7c986df74c645c0ac54639741c90a557
Client> 2013-10-07 21:27:59 [iNFO] [ForgeModLoader] Found valid fingerprint for Minecraft. Certificate fingerprint cd99959656f753dc28d863b46769f7f8fbaefcfc
Client> 2013-10-07 21:27:59 [iNFO] [sTDOUT] Adding AccessTransformer: nei_at.cfg
Client> 2013-10-07 21:27:59 [iNFO] [sTDOUT] Adding Accesstransformer map: temp.dat
Client> 2013-10-07 21:27:59 [iNFO] [sTDOUT] Loaded 54 rules from AccessTransformer config file temp.dat
Client> 2013-10-07 21:27:59 [iNFO] [ForgeModLoader] Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker
Client> 2013-10-07 21:27:59 [iNFO] [ForgeModLoader] Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker
Client> 2013-10-07 21:28:00 [iNFO] [ForgeModLoader] Launching wrapped minecraft {net.minecraft.client.main.Main}
Client> 2013-10-07 21:28:03 [iNFO] [sTDOUT] Inserted super call into axv.c
Client> 2013-10-07 21:28:03 [iNFO] [sTDOUT] awy was overriden from NotEnoughItems 1.6.1.5.jar
Client> 2013-10-07 21:28:04 [iNFO] [Minecraft-Client] Setting user: SackCastellon
Client> 2013-10-07 21:28:04 [iNFO] [Minecraft-Client] (Session ID is token:90ca425180524de0bdcc3be3136f8b06:6cac2c21103b48159c90a79568a3638d)
Client> 2013-10-07 21:28:04 [iNFO] [sTDOUT] Class aqz patched!
Client> 2013-10-07 21:28:04 [sEVERE] [ForgeModLoader] Unable to launch
Client> java.lang.reflect.InvocationTargetException
Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
Client> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
Client> 	at java.lang.reflect.Method.invoke(Unknown Source)
Client> 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
Client> 	at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
Client> Caused by: java.lang.NoClassDefFoundError: net/minecraft/block/Block
Client> 	at net.minecraft.stats.StatList.func_75921_a(StatList.java:185)
Client> 	at net.minecraft.stats.StatList.<clinit>(StatList.java:96)
Client> 	at net.minecraft.client.Minecraft.<init>(Minecraft.java:329)
Client> 	at net.minecraft.client.main.Main.main(SourceFile:83)
Client> 	... 6 more
Client> Caused by: java.lang.ClassNotFoundException: net.minecraft.block.Block
Client> 	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186)
Client> 	at java.lang.ClassLoader.loadClass(Unknown Source)
Client> 	at java.lang.ClassLoader.loadClass(Unknown Source)
Client> 	... 10 more
Client> Caused by: java.lang.NullPointerException
Client> 	at org.objectweb.asm.Item.a(Unknown Source)
Client> 	at org.objectweb.asm.ClassWriter.a(Unknown Source)
Client> 	at org.objectweb.asm.ClassWriter.newClass(Unknown Source)
Client> 	at org.objectweb.asm.ClassWriter.visit(Unknown Source)
Client> 	at org.objectweb.asm.ClassVisitor.visit(Unknown Source)
Client> 	at org.objectweb.asm.commons.RemappingClassAdapter.visit(Unknown Source)
Client> 	at cpw.mods.fml.common.asm.transformers.deobf.FMLRemappingAdapter.visit(FMLRemappingAdapter.java:33)
Client> 	at org.objectweb.asm.ClassReader.accept(Unknown Source)
Client> 	at org.objectweb.asm.ClassReader.accept(Unknown Source)
Client> 	at cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer.transform(DeobfuscationTransformer.java:39)
Client> 	at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:274)
Client> 	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:172)
Client> 	... 12 more
Game ended with no troubles detected (exit code 0)
Deleting C:\Users\xxxxxx\AppData\Roaming\.minecraft\versions\1.6.4-Forge9.11.1.916\1.6.4-Forge9.11.1.916-natives-6111697258571
Couldn't delete C:\Users\xxxxxx\AppData\Roaming\.minecraft\versions\1.6.4-Forge9.11.1.916\1.6.4-Forge9.11.1.916-natives-6111697258571 - scheduling for deletion upon exit

 

 

ClassTransformer.class

package SackCastellon.stainedsand.asm;

import java.io.File;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import SackCastellon.stainedsand.library.Reference;

import net.minecraft.launchwrapper.IClassTransformer;

public class ClassTransformer implements IClassTransformer {

@Override
public byte[] transform(String arg0, String arg1, byte[] arg2) {

	if (arg0.equals("aqz") || arg0.equals("net.minecraft.block.Block")) {
		arg2 = patchClassInJar(arg0, arg2, arg0, FMLLoadingPlugin.location);
	}
	return arg2;
}

public byte[] patchClassInJar(String name, byte[] bytes, String ObfName, File location) {
	try {
		ZipFile zip = new ZipFile(location);
		ZipEntry entry = zip.getEntry(name.replace('.', '/') + ".class");

		if (entry == null) {
			System.out.println("[" + Reference.MODID + "] " + name + " not found in " + location.getName());
		} else {

			InputStream zin = zip.getInputStream(entry);
			bytes = new byte[(int) entry.getSize()];
			zin.read(bytes);
			zin.close();
			System.out.println("Class " + name + " patched!");
		}
		zip.close();
	} catch (Exception e) {
		throw new RuntimeException("[" + Reference.MODID + "] Error overriding " + name + " from " + location.getName(), e);
	}

	return bytes;
}
}

 

 

FMLLoadingPlugin.class

package SackCastellon.stainedsand.asm;

import java.io.File;
import java.util.Map;

import cpw.mods.fml.relauncher.IFMLLoadingPlugin;

public class FMLLoadingPlugin implements IFMLLoadingPlugin {

public static File location;

@Override
public String[] getASMTransformerClass() {
return new String[]{ClassTransformer.class.getName()};
}

@Override
public void injectData(Map<String, Object> data) {
location = (File) data.get("coremodLocation");
}

@Override
@Deprecated
public String[] getLibraryRequestClass() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getModContainerClass() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getSetupClass() {
	// TODO Auto-generated method stub
	return null;
}

}

 

I hope you can help me. Thanks  :)

Link to comment
Share on other sites

ASM is hard, and throws weird errors. Combine that with the fact that only few people know how to use it properly and it's thereby hard to find help for problems related to it, well you will need to be quite proficient in java.

 

Now that being said, I have to ask one thing; What are you trying to do which you need to utilize ASM for? :)

As in what are you trying to achieve? :)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

What are you trying to do which you need to utilize ASM for? :)

As in what are you trying to achieve? :)

 

First, it only was a test. I was trying to add one of my mod's block to the canSustainPlant() method, to make my block able to sustain cactus. (i know it can be made by another way, that's why it was only a test)

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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