Jump to content

Recommended Posts

Posted

So, I'm modding in Intellig and using this:

 

return ReflectionHelper.getPrivateValue(SoundHandler.class, getSoundHandler(), "sndManager");

Which works fine until I try it in the actual minecraft game.  Then I get an error:

ReflectionHelper$UnableToAccessFieldException ... java.lang.NoSuchFieldException: sndManager

 

So it seems the field has changed.  How do I tell what I should use for a field that will work in minecraft and build in dev?

 

I'm building for 1.7.10-10.13.0.1207 btw.

 

Posted

You are using the deobfuscated name, so it will work in the dev environment, but in the non-dev environment, the name is deobfuscated and is changed, so that's why it doesn't work. You need to check if you in a dev environment or not, and use the appropriate name for that.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

You need to use the srg name in the obfuscated version of your mod.

You can find them at C:\Users\{YOUR_USER}\.gradle\caches\minecraft\net\minecraftforge\forge\{VERSION}\srgs\mcp-srg.srg

 

So for this one I took the time to find it for you, it's 'field_147694_f'. So your code would look like:

return ReflectionHelper.getPrivateValue(SoundHandler.class, getSoundHandler(), "sndManager", "field_147694_f");

 

Also, if this method is being called frequently, consider saving the 'Field' instance somewhere, and just calling Field#get(Object) on it.

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

Posted

Thanks!  That works!

 

I also noticed the ReflectionHelper is overloaded to allow checking by index of field.  Was going to try and see if that works as well; might be quicker to use in the future.

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.