Jump to content

Recommended Posts

Posted

I have the strangest error with my mod. When running the mod in the dev environment (Eclipse) the mod works fine. Once I have run 'gradlew build' and taken the .jar into my Forge install's mods folder, the mod stops working. When booting up minecraft I get the error

[22:10:37 INFO]: Client> java.lang.NoSuchFieldException: tileSign
[22:10:37 INFO]: Client> 	at java.lang.Class.getDeclaredField(Unknown Source)
[22:10:37 INFO]: Client> 	at cad97.commandblocksigns.CommandBlockSignsMFListener.<clinit>(CommandBlockSignsMFListener.java:22)
[22:10:37 INFO]: Client> 	at cad97.commandblocksigns.CommandBlockSigns.preinit(CommandBlockSigns.java:29)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at java.lang.reflect.Method.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at java.lang.reflect.Method.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventBus.post(EventBus.java:267)
[22:10:37 INFO]: Client> 	at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
[22:10:37 INFO]: Client> 	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at java.lang.reflect.Method.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
[22:10:37 INFO]: Client> 	at com.google.common.eventbus.EventBus.post(EventBus.java:267)
[22:10:37 INFO]: Client> 	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
[22:10:37 INFO]: Client> 	at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:512)
[22:10:37 INFO]: Client> 	at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239)
[22:10:37 INFO]: Client> 	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467)
[22:10:37 INFO]: Client> 	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:815)
[22:10:37 INFO]: Client> 	at net.minecraft.client.main.Main.main(SourceFile:103)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[22:10:37 INFO]: Client> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at java.lang.reflect.Method.invoke(Unknown Source)
[22:10:37 INFO]: Client> 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
[22:10:37 INFO]: Client> 	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

from the static constructor in my FMLListener class. I and some other modders on the forums had decided earlier (http://www.minecraftforge.net/forum/index.php/topic,20082) that reflection was probably the best way to go about grabbing the TileEntitySign from the GUISignEdit. However, this seems to be causing a problem now.

 

I'm stumped as for the difference between the dev environment and the standard environment - it must be something with the deobfuscated environment of dev versus the standard environment. If you want a closer look at my code, here is the GitHub repo: https://github.com/CAD97/CommandBlockSigns/tree/master

Posted

This is quite a simple error really... You are using a deobfuscated name which means it will only work in the dev environment... You will have to find the obfuscated name and use that (it would be best to use a boolean in your main mod class called isDevEnvironment equal to true for when your developing, then set to false when you are going to release the mod).

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

So I'd be referring to the class by its

private static final String __OBFID = "CL_00000764";

?

 

/goes to try after closing the dozen open Chrome tabs on this forum

 

EDIT: well it's not that simple at least as i can't refer to a class CL_00000764 (it's a compile error) and don't know what to do here.

Posted

Go to "the folder forge installed in/build/unpacked/conf/" and open file "packaged.srg" with WordPad and search for a due obfuscated class name you are reflecting, as an example, I'll reflect EntityCreeper. I search "EntityCreeper" and it will find a line, that contains this:

CL: wl net/Minecraft/entity/monster/EntityCreeper

"wl" is EntytyCreeper's class obfuscated name.

Posted

Thanks diesieben! I think the thing here is that with reflection you give it a string to find the field. If it were a variable the 'gradlew build' would catch it and obfuscate it to field_*****_X, but it doesn't change the String.

(Just a guess, is not necessarily true.)

This would be why you can reference the ex. EntityCreeper.class by name - even if it is referred to as wl.class in the standard environment, when you run 'gradlew build' the script catches the fact that you want EntityCreeper.class and changes the call to be the correct name.

 

NOW, apart from my speculation on the inner workings on Forge,

 

About how often should I expect to have to go find the fields.scv file to update the reflection? Should I expect it to keep working for most 1.7.4 forge builds or will I most likely have to update it every forge revision?

 

{For those who really want to see the change that I made, go to the FMLListener class on the github project.}

 

[spoiler=other]

The funny thing is that I still got an error, but this one is non-fatal and is totally Minecraft's fault, not mine.

[10:15:16 INFO]: Client> Exception in thread "Thread-9" java.lang.NullPointerException
[10:15:16 INFO]: Client> 	at paulscode.sound.codecs.CodecJOrbis.readBytes(CodecJOrbis.java:643)
[10:15:16 INFO]: Client> 	at paulscode.sound.codecs.CodecJOrbis.read(CodecJOrbis.java:354)
[10:15:16 INFO]: Client> 	at paulscode.sound.Source.stream(Source.java:953)
[10:15:16 INFO]: Client> 	at paulscode.sound.StreamThread.run(StreamThread.java:129)

I'll be hosting the actual mod .jar on minecraft.curseforge later - right now I've got to go and do normal things.

 

 

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.