Neither can I. I opened the .jar file downloaded directly from the site in jd gui. I saved the entire source as a .zip, and extracted its contents directly to the src folder of my netbeans project, so it should have been exactly the same as the original .jar. When I tried to build it, though, it gave me errors. What could I have done wrong?
Sage Pourpre, in your original post, you said to modify the jar file directly in the archive. How can you do that? Don't you have to extract a class file to open it in jd gui and netbeans?
In fact, you do both things.
You have to extract your minecraft.jar into a folder
Then, you decompile class files to .java with Jd-gui
You make all the modifications you need and recompile modified .java back to .class
Then, you open the minecraft.jar archive using 7-zip.
Finally, you drag & drop modified class files into the jar files.
Don't forget to delete meta-inf directory and making the assumption
your mod is well done, the game should launch normally, except, with your
It seemed weird to me, it shouldn't be possible to compile a single .java file to a .class file (in this case), as it would be missing objects declared in other classes. A compiler would just find errors because it's using objects that weren't declared and would never be able to compile it. That's why the only way you'd be able to compile a modded minecraft server is by creating a project with all of the files needed, and turning it directly into a jar from netbeans, but if you read a few posts up, you can see that I had issues doing that, too
Edit: I'm gonna send a PM to superllama, asking him how he's recompiling his mods
Presumably if you take the one class and compile it with the original jar in the class path, it should be able to link against the standard classes. So that would be how you only compile however many files you modified. I just don't know how to do this.
After you decompile the class files you will have LOTS of errors. Recompiling the decompiled code would take a ton of time and effort. And the next update would just invalidate it. So, to mod you have to pick out the certain classes for change. JD-GUI does a pretty good job but there are many classes missing class variables that you will have to careful fix yourself. In Eclipse I created a project with the decompiled source code and included the other jars as Libraries. From there I went to Project Properties->Java Compiler->Errors/Warnings. Check "Enable project specific settings". At the very bottom uncheck "Treat errors like fatal compiler errors". The classes will compile but there is no saying if they will work. This means you have to inject only your modified classes in to minecraft.jar and test them. Because the jar is signed you will need to remove everything but MANIFEST.MF from the META-INF folder in the jar file.
One problematic class is called "if.java". Being that "if" is a keyword I do not know if it is compiled correctly in any generated class files that reference it. Since I haven't worked on a class with a reference to that I am unsure.
I still can't seem to get that far. I mean, I tried doing exactly what you said, but it didn't change whatever is holding me up. I added minecraft_server.jar to the class path, and it appears under referenced libraries, but no matter what I do, Eclipse says "The import ai cannot be resolved", referring to the first line of minecraft_server.java. Then hundreds of errors, one for each import and another each time something that would have been defined in that import is used.
I feel like I'm missing something super obvious. The import statement is not searching the default package (or I guess, unpackaged) classes in the jar. From what I know about Java, it's not supposed to search there. But clearly you've gotten it to do something that has worked.
Ok, I almost have it figured out. Just follow these steps:
1. Create a new project in Netbeans
2. Extract the files from the original minecraft_server.jar to any empty folder
3. Right click the project name on the left of the screen in Netbeans and go to properties -> libraries -> compile (tab)
4. Go to add Jar/Folder, and add the folder created in step 2
5. Now, add a .java file to the source packages (whichever one you want to edit, should have already decompiled it in jd-gui)
6. Once you have finished editing this java file, right click the java file on the left and select compile file
7. Look at the directory give at the bottom of the window, that's where you'll find the class file. Add this file to the original server jar file
That should do it, I can't get step 7 to work. I even tried just extracting minecraft_server to a folder and making them a jar using winrar, and it said it was corrupt (even though it has the exact same folders as the original, which works for me). If anyone can tell me how to make the new jar properly, that would be appreciated
Edit: Never mind, I downloaded the program that Pourpre used (7-zip), and it worked fine. Everyone follow the steps I listed above, it works
Alright, I gave up trying to edit MinecraftServer.java. It's just not going to compile and I cannot for the life of me figure out why.
Other classes compile fine. The way I'm doing things is a little different than blitz but those directions are basically the same. If anyone has managed to edit and recompile MinecraftServer.java and lived to tell the tale, would you care to share?
Sorry to keep bumping this thread, but when I said I was giving up on MinecraftServer.java, I lied.
So I got the import errors to go away. I did this by deleting the import statements and moving MinecraftServer.java into the default package for my project. So xau was right there. If you do both, it can see the packageless class files.
Next I edited the file so that it is valid java. Renaming local variables, restoring lost object types and template types, correcting little things like the same name being used for a String and a String. That's done. Now I'm down to 8 errors. All of them seem to be in classes which refer to the MineCraft server its self.
The constructor bm(String, MinecraftServer) is undefined MinecraftServer.java /mc_mod/src line 489 Java Problem
The constructor bn(MinecraftServer) is undefined MinecraftServer.java /mc_mod/src line 43 Java Problem
The constructor bp(MinecraftServer) is undefined MinecraftServer.java /mc_mod/src line 38 Java Problem
The constructor dc(MinecraftServer, InetAddress, int) is undefined MinecraftServer.java /mc_mod/src line 67 Java Problem
The constructor eb(MinecraftServer) is undefined MinecraftServer.java /mc_mod/src line 96 Java Problem
The constructor ft(MinecraftServer) is undefined MinecraftServer.java /mc_mod/src line 82 Java Problem
The constructor fw(MinecraftServer) is undefined MinecraftServer.java /mc_mod/src line 83 Java Problem
The method a(MinecraftServer) in the type fo is not applicable for the arguments (MinecraftServer) MinecraftServer.java /mc_mod/src line 486 Java Problem
Basically, any time a constructor is called for a class that takes a MinecraftServer object as its argument, the compiler complains that MinecraftServer is undefined. I think this might be because of the way I tricked it into seeing the other class files by putting it in the default package. Because if you look in the source for, say, bm, the first line is:
Which obviously is not going to exist because I moved it out of that package. Any thoughts?
I don't know how you'd edit that, I tried putting the java in the same directory it ends up in, but it didn't work. Not sure if there's a way to edit it, but it doesn't seem like an essential file to mod.
Does anyone know commands to use? His code is so hard to read since his variables are all 1 letter
I like the idea here. The main problem is, at least for me, I have trouble finding which classes I want to modify due to the obfuscation. It is so inconvenient every update for me to go through all the classes to find what I want. If there was an updated list that was collaboratively updated that would be fantastic. Of course, I feel like Notch would frown upon such a practice.