Ok. To start off, I'll let you know, that i HAVE NO IDEA how it works, this is for people(*cough cough* sk) to tell other people how it, and their minecraft... additions... work. About a year ago, I decided that I wanted to learn a programming language, this was just after I discovered minecraft, so, of course, without thinking, I got straight in. And now when I see java code that I didn't write (By the way, I am rubbish) my head explodes. I really want to develop stuff in java, and my way of learning, is to actually do it, or in this case, use other peoples code to understand it better in such a way that I can develop better applications. So, any java coders (*cough cough* sk89q), if you WANT to, please explain a smallish chunk of your code on this thread. Thank you.
I'm willing to help if you have something more specific that you want me to explain. I also learn by looking at code so I know where you are coming from. Try looking at my Bukkit plugins and feel free to ask questions on how they work.
YAY!!!! To start off with, how does the skcraft launcher work? because I looked through it, and found that the main method was empty. Also, I don't understand the $1 $2 stuff at the end of the class name. Thanks
doesn't seem empty to me... https://github.com/sk89q/skmclaunch.../java/com/sk89q/mclauncher/Launcher.java#L490
Are you decompiling the code? It's much easier to browse the source on GitHub (there's a easy source download link somewhere). The launcher itself is a relatively basic Swing (Java's GUI) application. Most of the stuff isn't anything special, but the launching of Minecraft and the loading of mods are two things that you are most likely interested in. For launching Minecraft, the launcher essentially calls the main method of the minecraft.jar. Of course, there's a specific way to do it so the game shows up properly. For the mod loading, the launcher uses reflection to accomplish this. In layman's terms, the launcher copies class files into the .jar before the main method of Minecraft is called. It's been hard-coded to handle different mods (such as ModLoader) differently as appropriate. I'm personally not the most well-versed in reflection, so sk has a better idea than me...
The $1 and $2 are anonymous classes that are generated by compilation. I recommend checking the original source on GitHub. Also, a fair warning: my code tends to be abstract and utilizes a lot of more advance language features and so you're usually better off reading other people's code... My launcher is fairly simple though.
I extracted the files from the .jar then I used xcode to read the .class files, of which ALL methods etc. were empty.
I still don't understand most of the code. perhaps you could explain to me the most simple of those files. (my current level is starting GUIs)
Have you started at https://github.com/sk89q/skmclaunch.../java/com/sk89q/mclauncher/Launcher.java#L490 ?
Ok thanks, I now understand that main method, but most of the rest still knocks me out. Sorry for being such a slow learner, I hope you don't get impatient when you see my replies.
Do you want to start with the launcher to learn with? You'd have to both learn regular Java and GUI at the same time, which is, of course, by all means doable.