Jump to content

[1.9] Where can I find the vanilla Minecraft methods, if possible? [Solved]


HyperHamster

Recommended Posts

If I knew where to look to see all of Minecraft's methods I feel I could better understand what it is I'm doing. I've looked inside the so called "deobfuscated" uncompiled Minecraft code that you get when you run "gradle setupDecompWorkspace", but all I find are arbitrary method names such as "func_123456_a" and so on.

 

I have a specific instance where I would like to know the method to a play a sound within a world. So I went to "net/minecraft/world/World.java" but all the methods names are obfuscated. Where would I look to find the true method names within this file?

Link to comment
Share on other sites

Are you looking at the code in your IDE or manually opening a JAR? Your IDE should show you the deobfuscated source code when you open a vanilla class.

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

Are you looking at the code in your IDE or manually opening a JAR? Your IDE should show you the deobfuscated source code when you open a vanilla class.

 

After running "gradle setupDecompWorkspace" I extracted the jar located at "/build/tmp/decompileMc/forge-1.9-12.16.0.1854-1.9-srgBin.jar" to a directory of the same name at the same location. I then opened the file located at "/build/tmp/decompileMc/forge-1.9-12.16.0.1854-1.9-srgBin/net/minecraft/world/World.java" with my IDE.

 

Here is a snippet of the contents demonstrating the arbitrary method/parameter names:

   public boolean func_175691_a(BlockPos p_175691_1_, Block p_175691_2_) {
      return false;
   }

   public boolean func_175678_i(BlockPos p_175678_1_) {
      return this.func_175726_f(p_175678_1_).func_177444_d(p_175678_1_);
   }

   public boolean func_175710_j(BlockPos p_175710_1_) {
      if(p_175710_1_.func_177956_o() >= this.func_181545_F()) {
         return this.func_175678_i(p_175710_1_);
      } else {
         BlockPos blockpos = new BlockPos(p_175710_1_.func_177958_n(), this.func_181545_F(), p_175710_1_.func_177952_p());
         if(!this.func_175678_i(blockpos)) {
            return false;
         } else {
            for(blockpos = blockpos.func_177977_b(); blockpos.func_177956_o() > p_175710_1_.func_177956_o(); blockpos = blockpos.func_177977_b()) {
               IBlockState iblockstate = this.func_180495_p(blockpos);
               if(iblockstate.func_185891_c() > 0 && !iblockstate.func_185904_a().func_76224_d()) {
                  return false;
               }
            }

            return true;
         }
      }
   }

 

These method names are nothing like the ones I see people using from these classes when importing these classes into their mods. This is where my confusion lies.

Link to comment
Share on other sites

Don't manually open any JARs. Your IDE project has a forgeSrc library as a dependency, this contains the Minecraft/Forge classes with the source code attached to them. Simply open a class in this library and your IDE will show you the deobfuscated source code.

 

The JAR you tried to open is using SRG (semi-obfuscated) names, hence the srgBin classifier. build/tmp contains temporary files created by the build process, you should never need to use any of these files.

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

Don't manually open any JARs. Your IDE project has a forgeSrc library as a dependency, this contains the Minecraft/Forge classes with the source code attached to them. Simply open a class in this library and your IDE will show you the deobfuscated source code.

 

The JAR you tried to open is using SRG (semi-obfuscated) names, hence the srgBin classifier. build/tmp contains temporary files created by the build process, you should never need to use any of these files.

 

Okay, that makes a lot more sense, thank you. However I cannot locate a forgeSrc folder/library anywhere inside my mod directory. Can you please tell me where or how to either locate or acquire this?

 

Note: I'm am not using Eclipse or IntelliJ.

Link to comment
Share on other sites

You won't see the source code in your mod directory - you find it using your IDE by looking in the referenced libraries.

 

The actual location of the setupDecompWorkspace output varies but is usually found in a folder somewhere under your /%User%/ directory. You can find out by checking the path of the forgeSrc entry under your IDE's referenced libraries.

 

EDIT: Sorry, didn't see your note about not using an IDE :\

Link to comment
Share on other sites

Ah, I assumed you were using an IDE project generated by ForgeGradle. If you've created the project yourself it probably doesn't have the dependencies specified by ForgeGradle.

 

If your mod and the mods it depends on (if any) aren't using any access transformers, you can find the compiled forgeSrc library in the Gradle cache: ~/.gradle/caches/minecraft/net/minecraftforge/forge/<forge_version>/<mcp_mappings_channel>/<mcp_mappings_version>/forgeSrc-<forge_version>.jar (replace ~ with %USERPROFILE% on Windows)

 

If you are using access transformers, you can find the compiled forgeSrc library in your ForgeGradle workspace: <workspace_dir>/.gradle/minecraft/forgeSrc-<forge_version>-PROJECT(<project_name>).jar

 

In both cases, the JAR containing the source code will be in the same directory with the -sources classifier.

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

Well coolAlias's reply inspired me to go back and re-run "gradle setupDecompWorkspace" again but this time with "-d" debug flag and that showed it outputting forgeSrc into my Gradle cache exactly where your later reply Choonster said it would be. It's a shame I found it before I refreshed to see your reply, Choonster. At least it's location has been layed out elegantly for anybody else who has the same confusion I had. Thank you Choonster and coolAlias both very much for your help.

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



×
×
  • Create New...

Important Information

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