Jump to content

Dev environment / Build environment diff


cad97

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

 

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

    • How to fix file server-1.20.1-20230612.114412-srg.jar  
    • Just a few months ago I was creating my own plugin for Minecraft 1.20.2 spigot that did the same thing, but the skins were not saved, if you can understand this code that I made a long time ago it may help you.   //This is a class method private static String APIRequest(String value, String url, String toSearch) { try { URL api = new URL(url + value); HttpURLConnection connection = (HttpURLConnection) api.openConnection(); connection.setRequestMethod("GET"); int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder response = new StringBuilder(); for (String responseChar; (responseChar = reader.readLine()) != null; ) response.append(responseChar); reader.close(); JSONObject responseObject = new JSONObject(response.toString()); if (!toSearch.equals("id")) return responseObject .getJSONArray("properties") .getJSONObject(0) .getString("value"); else return responseObject.getString("id"); } else { AntiGianka.ConsoleMessage(ChatColor.RED, String.format( "Could not get %s. Response code: %s", ((toSearch.equals("id")) ? "UUID" : "texture"), responseCode )); } } catch (MalformedURLException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } catch (IOException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while attempting to connect to the URL. Error: " + error); } return ""; } //other class method private void SkinGetter() { String uuid; String textureCoded; if ((uuid = APIRequest(args[0], "https://api.mojang.com/users/profiles/minecraft/", "id")).isEmpty() || (textureCoded = APIRequest(uuid, "https://sessionserver.mojang.com/session/minecraft/profile/", "value")).isEmpty() ) sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); else SkinSetter(textureCoded); } //other more private void SkinSetter(String textureCoded) { JSONObject profile = new JSONObject(new String(Base64.getDecoder().decode(textureCoded))); try { URL textureUrl = new URL(profile.getJSONObject("textures"). getJSONObject("SKIN"). getString("url")); if (sender instanceof Player && args.length == 1) { PlayerTextures playerTextures = ((Player) sender).getPlayerProfile().getTextures(); playerTextures.setSkin(textureUrl); ((Player) sender).getPlayerProfile().setTextures(playerTextures); if (((Player) sender).getPlayerProfile().getTextures().getSkin() != null) sender.sendMessage(((Player) sender).getPlayerProfile().getTextures().getSkin().toString()); else sender.sendMessage("Null"); sender.sendMessage("Skin changed successfully.a"); } else { } AntiGianka.ConsoleMessage(ChatColor.GREEN, "Skin command executed successfully."); } catch (MalformedURLException error) { sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } }  
    • Use /locate structure The chat should show all available structures as suggestion For the Ancient City it is /locate structure ancient_city
    • So does it work without this mod? Did you test it with other builds?
  • Topics

×
×
  • Create New...

Important Information

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