Jump to content

How to get method and variable names for ObfuscationReflectionHelper?


Recommended Posts

Posted

So, there is a code:

 

GuiSlot langlist = (GuiSlot) ObfuscationReflectionHelper.getPrivateValue(GuiLanguage.class, this, new String[]{"field_146450_f"});

 

My question is: how to get field names like "field_146450_f" from minecraft.jar? I tried to decompile it and I saw names only like "il", "ij"...

Posted

You can get the SRG name of a method/field from the MCP mapping CSVs.

 

If you've set up a ForgeGradle workspace for 1.8+, you can find the MCP mappings used by it in the Gradle cache (~/.gradle/caches/minecraft/de/oceanlabs/mcp/<mappings_channel>/<mappings_version>, replace ~ with %USERPROFILE% on Windows).

 

You can also download MCP mappings from the MCPBot website.

  • Thanks 1

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.

Posted

If you set up your ForgeGradle workspace with

setupDecompWorkspace

(not

setupDevWorkspace

) and then generate your IDE project, the forgeSrc library will have the deobfuscated Minecraft/Forge source code attached to it. This means you can view the source code of each class in your IDE.

 

Just to clarify, there are three types of names:

  • Notch - Fully obfuscated names like
    aa

    /

    ij

    . These used in the standard Minecraft JAR.

  • SRG/Searge - Auto-generated, semi-obfuscated names like
    field_0035_a

    /

    func_0001_b

    . Forge deobfuscates the standard Minecraft JAR at runtime to use these names.

  • MCP - Deobfuscated names like
    thingList

    /

    getThingList

    . These are only used in the development environment, ForgeGradle reobfuscates your code to use SRG names when you build it.

 

The MCP mapping CSVs map from SRG to MCP names.

 

Notch names change with every version of Minecraft. SRG names are fairly stable, they will usually remain the same across multiple versions of Minecraft. MCP names can change with each mapping version.

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.

Posted

It's ok but I need not just names but whole source files with SRG names.

If mod is applying a patch to the game, i need to provide a patch with SRG names or MCP?

Posted

It's ok but I need not just names but whole source files with SRG names.

 

Why?

 

There should be a JAR in your Gradle cache that contains the Minecraft and Forge classes with SRG names. For recent versions of Forge, this can be found at ~/.gradle/caches/minecraft/net/minecraftforge/forge/<forge_version>/<mappings_channel>/<mappings_version>/forge-<forge_version>-srgBin.jar (replace ~ with %USERPROFILE% on Windows).

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.

Posted

I think I need a file with SRG names because mod is applying .patch to the game. Or I'm wrong and I can use normal MCP files to create a patch?

But there is .class files, not .java in ...-srgBin.jar.

Posted

Coremods don't apply a traditional .patch file to the Minecraft source code, they modify the bytecode at runtime using ASM. You should only need to know a couple of SRG names at a time, you don't need the whole codebase in SRG names.

 

You can use a decompiler like Bytecode Viewer to decompile bytecode into Java.

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.

Posted

Unfortunately BytecodeViewer and other decompilers provide inaccurate result. And now I have "java.lang.NoClassDefFoundError: net/minecraft/client/gui/FontRenderer".

Mod is trying to patch class FontRenderer. I checked, all changes are valid.

So the problem is in inaccurate sources from decompilation.

Posted

I just need normal font for Unicode non-latin character when scaling is below 1.0. Now it looks crappy and I can't read it.

There is a bunch of mods for 1.7.10 and below (Better Fonts, Client Fix, Unicode Font Fixer) but I can't port them!

 

Better Fonts allows to use ANY Windows font in the game. It uses patches.

Posted
Have you made a mod before? Have you programmed before? Do you know what Java bytecode is?

No. Yes, C#, JavaScript. No

 

There is NO up-to-date mods, which can help me!

 

And I'm not a fully dumb, I finally found FontRenderer sources with SRG names, I compared it with patch file and translated changes with new variable names. But I've got NotFoundClass exception.

Then I tried to use a patch file with minimal changes, just for test. Now it looks like:

--- build/tmp/recompSrc/net/minecraft/client/gui/FontRenderer.java 2016-01-23 19:35:18.000000000 +0100

+++ src/main/java/net/minecraft/client/gui/FontRenderer.java 2016-01-23 22:33:47.230136500 +0100

@@ -25,9 +25,9 @@

import net.minecraftforge.fml.relauncher.SideOnly;

import org.apache.commons.io.IOUtils;

import org.lwjgl.opengl.GL11;

-

+/*BetterFonts start*/ /*BetterFonts end*/

And what I got? NotFoundClass exception. Maybe it's a bug in the Forge?

Posted

There is no need for Better Fonts anymore with proper configuration files you can do everything that that achieved in MC 1.8 nativly.

On top of that Diesieben is correct, you should not be editing vanilla classes if you have no idea what you are doing.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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