jakj Posted May 5, 2012 Posted May 5, 2012 Ever wanted to figure out just how complex and intricate IC2's power grid really is? Tired of guessing at what all those Thaumcraft items and objects really do? Admire the amazing Steve's Carts and want to add your own new cart type? Frustrated by trying to understand partially-obfuscated mod code and just want the answers you seek? Read on. Important note #1: Do not distribute the decompiled source code of a mod. Mod authors get pissy if you do that, and then you have that piss smell all over the place. Important note #2: Do not just copy/paste other mods' code into your own. Don't be a lazy plagiarist. (When a .bat file is referenced, that is obviously for Windows only. The rest of you should be using the .py (Python) scripts, as usual.) Basic steps: [li]Get the appropriate version of MCP. (If that confused you, you really should not be in this section.)[/li] [li]Run the updatemcp.bat inside MCP until it says there are no updates.[/li] [li]Get a fresh copy of minecraft.jar (using MCNostalgia if necessary).[/li] [li]If the mod requires Modloader, get the version of Modloader you need and put it in your minecraft.jar.[/li] [li]If the mod requires Forge, get the CLIENT version of Forge you need, and put it in your minecraft.jar. (You will not be using the source version of Forge for this method.)[/li] [li]If the mod requires any other mod, get the client version of the mod you need, and put everything (absolutely everything) in your minecraft.jar (not the mods directory that MCP may have created).[/li] [li]Open the .zip or .jar the mod is in, and put everything (absolutely everything) in your minecraft.jar (not the mods directory that MCP may have created).[/li] [li]Put the minecraft.jar in the right place in your MCP installation, then run decompile.bat.[/li] Now, if you're very lucky, that will work. What is more likely is you will get an error from Retroguard saying a particular class cannot be found. That means the mod requires something that is not there, and you need to find it. An example is Mo' Creatures: If you take the MoCreatures.zip out of the Technic 6.0.7 (1.1) installation, and you try to decompile it, Retroguard complains about things like SettingBoolean being missing. In this case, you would go back into your Technic installation, open the modpack.jar, find SettingBoolean.class, and stick that in the minecraft.jar you have in your MCP installation for decompilation. Repeat that step for each missing class file (this may take a while, as you work your way back through a mod's entire set of dependencies), and each time, run the decompile.bat script again. (Do not run the cleanup script; There is no need. Just try to decompile again immediately. But if something screws up horribly, go ahead and run the cleanup and see if that helps. Always keep backups at different stages of this process, so all you have to do is copy/paste your directory and start over, instead of re-doing multiple steps.) Another example may be a missing Forge class: This is an error I encounter frequently, when I install Forge from a download but copy a mod out of Technic to decompile. Just go into your modpack.jar and find it, and put it in. (As far as I know, this is a known issue in Forge that may or may not have already been corrected.) Remember: The point is not to try to get a working minecraft.jar, but rather, just to get one that decompiles. So once you have the mod you're trying to decompile in there, it doesn't matter what else you stick in there, because you will ignore it; All that matters is the mod. Finally, the decompilation should succeed. MCP will continue through its steps, cleaning up sources and adding comments, and so forth. Once it says it is recompiling, you can CTRL-c (or whatever) out of it, or just wait: It will vomit all over itself and fail to recompile. Ignore that; You have what you need. Go into the "src" directory, and your decompiled files will be in there, deobfuscated and fresh, ready for you to read and take in. Remember, don't distribute and don't plagiarize, but otherwise, learn and grow, and post if you have any issues. I won't help idiots, but I will help people who genuinely want to learn. After all, the best way to learn Minecraft modding is to look at Minecraft's decompiled source code. Mods are just an extension of that.
miniboxer Posted August 13, 2012 Posted August 13, 2012 wow, this was incredibly useful, so I am going to suggest it for a sticky, as I was wondering how redpower frames work, decompiled the code, and realized it was beyond me.
milcondoin Posted August 13, 2012 Posted August 13, 2012 As long as you only want to read the code and not edit/recompile it, it will be easier to use http://java.decompiler.free.fr/?q=jdgui for this. Just open the .zip/.jar of the mod and maybe minecraft.jar and modpack.jar. Automatic linking to the appropiate class files will be given automatically. Biggest drawback of this method is, that you will still have the obfuscated classes of vanilla minecraft. (ItemStack.class is still aan.class, ...)
jakj Posted August 14, 2012 Author Posted August 14, 2012 I know you mean well, but anyone who needs a thread like this will just suffer cranial hemorrhage upon encountering obfuscated classes. Once you're able to understand them, you're not looking here for help.
Xenthera Posted September 19, 2012 Posted September 19, 2012 Hey man, (or woman) Thanks a lot for this. I'm just a wee lad in the programming world, and being able to learn directly from the source code really helps me out. Ususally on the IRC channels no one wants to help a sorry bloke like me... Again, thanks a lot.
forresthopkinsa Posted March 17, 2013 Posted March 17, 2013 I know you mean well, but anyone who needs a thread like this will just suffer cranial hemorrhage upon encountering obfuscated classes. Once you're able to understand them, you're not looking here for help. I understand the obfuscation perfectly; I just accidentally ran the cleanup script without a backup ^.^ I was just here to find another way where I didn't have to worry about obfuscation. Since your method did not work for me, I am using JDgui now, and although it's harder, it's very much possible.
forresthopkinsa Posted March 17, 2013 Posted March 17, 2013 · Hidden Hidden I know you mean well, but anyone who needs a thread like this will just suffer cranial hemorrhage upon encountering obfuscated classes. Once you're able to understand them, you're not looking here for help. I understand the obfuscation perfectly; I just accidentally ran the cleanup script without a backup ^.^ I was just here to find another way where I didn't have to worry about obfuscation. Since your method did not work for me, I am using JDgui now, and although it's harder, it's very much possible.
Recommended Posts