Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.8.9] Using reflection to change ItemArmor : NoSuchFieldException on mc server

Featured Replies

Posted

Good evening,

 

I'm currently trying to get a field from the ItemArmor class : ItemArmor.maxDamageArray. Using the ReflectionHelper, it works great on Minecraft Client and Minecraft Server configurations.

 

However, I've tested the mod on a friend's server and it doesn't work : NoSuchFieldException. At first, I was using a string to retrieve the field (maxDamageArray), it didn't work. Then I tried to get the value from the declared fields array, it didn't work. I was really surprised to see that it didn't work. Then I took a look at the vanilla server.jar and all the classes (and surely the fields) were obfuscated : I felt really stupid but I learnt something new so it's okay.

 

From now, I suppose I have two ways : either I have to get a deobfuscated version of the server to get it work, or I have to work with the obfuscation which seems to be really complicated.

 

Could you advise me on what should I do now, or what should my friend do to get it work ?

 

By the way, he's using forge-1.8.9-11.15.1.1763-universal.jar

 

Thank you for your time and my apologizes if this is related to a Java issue.

 

EDIT: more info, I use gradlew build to build my mod so that my friend can put in on his server.

Squirrel ! Squirrel ! Squirrel !

Because you asked for a field named "maxDamageArray" not "field_77882_bY" which is what it will be in a runtime (not development) environment (at least, in 1.7.10, I can't find the mappings for 1.8.9 as quickly).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Because you asked for a field named "maxDamageArray" not "field_77882_bY" which is what it will be in a runtime (not development) environment (at least, in 1.7.10, I can't find the mappings for 1.8.9 as quickly).

 

Okay, so do I need to work with obfuscated fields or does he need to get a server deobfuscated version ?

Squirrel ! Squirrel ! Squirrel !

When you use reflection for vanilla fields/methods, you need to need to check both the SRG (

field_77882_bY

) and MCP (

maxDamageArray

) names to support the release (obfuscated) and development (deobfuscated) environments.

ReflectionHelper

supports this by allowing you to supply multiple names for a field/method.

 

You can find the SRG name of a field/method from the MCP mapping CSVs. If you've set up a ForgeGradle workspace, you can find the mappings used by it in ~/.gradle/caches/minecraft/de/oceanlabs/mcp/<mappings_channel>/<mappings_version> (replace ~ with %USERPROFILE on Windows).

 

You can also download mappings from the MCPBot website or ask MCPBot for individual names on IRC (more details on the website).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem 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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.