Jump to content

How to get method and variable names for ObfuscationReflectionHelper?


rinart73

Recommended Posts

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"...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
    • Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error:  Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?
  • Topics

×
×
  • Create New...

Important Information

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