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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am not using hardcoded recipes, I'm using Vanilla's already existing code for leather armor dying. (via extending and implementing DyeableArmorItem / DyeableLeatherItem respectively) I have actually figured out that it's something to do with registering item colors to the ItemColors instance, but I'm trying to figure out where exactly in my mod's code I would be placing a call to the required event handler. Unfortunately the tutorial is criminally undescriptive. The most I've found is that it has to be done during client initialization. I'm currently trying to do the necessary setup via hijacking the item registry since trying to modify the item classes directly (via using SubscribeEvent in the item's constructor didn't work. Class so far: // mrrp mrow - mcmod item painter v1.0 - catzrule ch package catzadvitems.init; import net.minecraft.client.color.item.ItemColors; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.client.event.ColorHandlerEvent; import catzadvitems.item.DyeableWoolArmorItem; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Painter { @ObjectHolder("cai:dyeable_wool_chestplate") public static final Item W_CHEST = null; @ObjectHolder("cai:dyeable_wool_leggings") public static final Item W_LEGS = null; @ObjectHolder("cai:dyeable_wool_boots") public static final Item W_SOCKS = null; public Painter() { // left blank, idk if forge throws a fit if constructors are missing, not taking the chance of it happening. } @SubscribeEvent public static void init(FMLClientSetupEvent event) { new Painter(); } @Mod.EventBusSubscriber private static class ForgeBusEvents { @SubscribeEvent public static void registerItemColors(ColorHandlerEvent.Item event) { ItemColors col = event.getItemColors(); col.register(DyeableUnderArmorItem::getItemDyedColor, W_CHEST, W_LEGS, W_SOCKS); //placeholder for other dye-able items here later.. } } } (for those wondering, i couldn't think of a creative wool helmet name)
    • nvm found out it was because i had create h and not f
    • Maybe there's something happening in the 'leather armor + dye' recipe itself that would be updating the held item texture?
    • @SubscribeEvent public static void onRenderPlayer(RenderPlayerEvent.Pre e) { e.setCanceled(true); model.renderToBuffer(e.getPoseStack(), pBuffer, e.getPackedLight(), 0f, 0f, 0f, 0f, 0f); //ToaPlayerRenderer.render(); } Since getting the render method from a separate class is proving to be bit of a brick wall for me (but seems to be the solution in older versions of minecraft/forge) I've decided to try and pursue using the renderToBuffer method directly from the model itself. I've tried this route before but can't figure out what variables to feed it for the vertexConsumer and still can't seem to figure it out; if this is even a path to pursue.  The vanilla model files do not include any form of render methods, and seem to be fully constructed from their layer definitions? Their renderer files seem to take their layers which are used by the render method in the vanilla MobRenderer class. But for modded entities we @Override this function and don't have to feed the method variables because of that? I assume that the render method in the extended renderer takes the layer definitions from the renderer classes which take those from the model files. Or maybe instead of trying to use a render method I should be calling the super from the renderer like   new ToaPlayerRenderer(context, false); Except I'm not sure what I would provide for context? There's a context method in the vanilla EntityRendererProvider class which doesn't look especially helpful. I've been trying something like <e.getEntity(), model<e.getEntity()>> since that generally seems to be what is provided to the renderers for context, but I don't know if it's THE context I'm looking for? Especially since the method being called doesn't want to take this or variations of this.   In short; I feel like I'm super super close but I have to be missing something obvious? Maybe this insane inane ramble post will provide some insight into this puzzle?
  • Topics

×
×
  • Create New...

Important Information

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