Minecraft Blogs / Tutorial

Anatomy of a Mod - Part II - Tools of the Trade

  • 503 views, 3 today
  • 1
  • 0
King Korihor's Avatar King Korihor
Level 34 : Artisan Modder
8
This blog entry is Part II of a series. Click on this link for the first part if you want to read from the beginning.

When you are trying to get into a software development project, one of the key early decisions you must make is to decide which tools you are going to use. Once you start going down a development path, it can be very difficult to change over to new tools so this is an important early decision to make.

In the case of developing Minecraft mods, the software development language was already decided upon by Marcus Persson (aka "Notch") in the form of Java. I've seen some professional software developers complain that it was a lousy choice, but in terms of being a way for beginning software developers to be able to get into the modding community and help extend the basic idea of the game, he couldn't have chosen a better language and still have some fairly reasonable performance. That Java runs on multiple operating systems where the same software will work in many places is an extra bonus.

Before you get started on developing any kind of Java software, one of the things you simply must do is to download a Java "Software Development Kit". In terms of working with Minecraft, you need to be using the Java "Standard Edition" development kit, sometimes simply abbreviated "Java SE SDK". Technically you only need (currently) version 6, but I'd recommend Java 7 for most of the work you do at the moment. Downloads for the SDK can be found here:

http://www.oracle.com/technetwork/java/javase/downloads/index.html


The next step is to find a good development environment. There are several different options for people who want to get into Java development, and they all have their supporters and critics. I'm going to list some of the key options below:

1 - Using an ordinary "text editor" and compiling from the command line: The nice thing about developing java applications in this manner is that it is very cheap (text editors come standard on every modern operating system and have been there for decades) and it gives you the most flexibility in terms of how you package your software. The problem is that this is for hardcore programmers only and you need to learn a style of computer programming that went out of style decades ago too. It does work, and even for mod development if you don't want to install a whole lot of additional software on your computer it works just fine.

2 - Eclipse (http://www.eclipse.org/) - This is a favorite for a great many people in the modding community. It is a software editor which can be used for several different computer programming languages and has some very good support for Java software development in particular. When you go to the forums, many of the long-time developers use this tool for their mod development efforts. Be warned though, it can be a bit intimidating to get set up in the first place and does need some technical competence before you can get your first mod started, but once you get established it is fairly easy to make tweaks and expand the project.

3 NetBeans (http://netbeans.org/) - This is my personal favorite. It is a software development tool which is written in Java so the people who made this software use NetBeans as their development environment. In other words, it was written with itself. It has a number of powerful features and I just happen to like the way that everything comes together.

I want to emphasize that your choice of software development tools is very much a personal choice and is more like choosing between European, American, or Japanese automobile brands if you were purchasing a car. They all get you to your destination, but some people happen to like a particular brand to take you on that journey and certainly have fans to support those choices. The same applies to software development environments. If you are new to this, experiment and try out some of the alternatives and make up your own mind. There are other options beyond even these tool choices, so go ahead and search around on forums and elsewhere to find those alternatives... but I would suggest at least checking out the above links first.

Once you have a solid development environment, you need to start learning about the internal structure of Minecraft as a game. By far and away the best resource for this (besides the Minecraft Wiki, which not only is useful for players but also helps with mod developers) is the "Minecraft Coder Pack", or MCP for short. I might go into a tutorial for how to set that up, but there are some excellent resources elsewhere that show how to get that accomplished. Follow the instructions to set it up, and you will gain access to what amounts to be almost as good as seeing the original source code that Mojang is using to develop Minecraft.

While bringing up MCP, I need to explain something here called "obfuscation". A few years ago a game called "Infiniminer" was developed by Zachary Barth. He released his software but because of the tools he was using it became very easy to "decompile" his software... and there were many people who got into "modding" this particular game including some flagrant copies and reselling those copies of the original. It became a huge mess and eventually the software developer simply quit making updates to Infinimer. But along the way Markus "Notch" Persson came along and was one of those who copied the idea and also spent some time looking at the original Infiniminer source code for some ideas.... that eventually did get put into Minecraft.

In part to keep the same thing happening to his effort, Notch employed a nifty piece of software called an "Obfuscator" which scrambles up the names. The end result of this is if you employe a "decompiler" to figure out how the software developer made the software for a language like Java, all you see is random letters and number that don't really give you any information about how the software was put together. A decompiler is software that turns raw "binary" data files back into the original software source code. Technically obfuscation is done for "legal" reasons, as you must go through an extra step to figure out how the software was written and try to give some more "real world language" names to some of those scrambled up names that came from the obfuscator. More importantly, it makes using a decompiler much more difficult.

While I'm on the subject of decompilers, I want to mention that it is an invaluable tool that you should have in your toolbox for mod development. While I have no tie to this developer, I'd like to plug a simple software tool called "Java Decompiler" or simply JD for short, written by Emmanuel Dupuy: http://java.decompiler.free.fr/ The software is free to download and has some powerful options, as well as plug-in options for Eclipse. There are other decompiler tools to consider.

Anyway, Minecraft has used an obfuscator since it was originally released, so a group of would-be mod developers got together and have been working to try and decypher all of the scrambled up names of the Minecraft releases in the form of the Minecraft Coder Pack. To keep things legal for the MCP team, you need to have purchased a legitimate copy of Minecraft and what their tools do is to "decompile" Minecraft back to the source codes, but they have taken the additional step of "deobfuscating" the scrambled up names as well.

If you want to understand why it sometimes can take a week or so (sometimes longer) from the time Minecraft updates until when mods seem to catch up and become compatible with Minecraft, this is the reason: When a new update happens, all of the names are scrambled up again but to completely new names. So the MCP team goes through the effort of taking all of the "plain English" names they had from the previous release and tries to match them up with the new software, and then if they are lucky that leaves just a few new files that they need to figure out what the Mojang developers have come up with and try to apply some new names to those new classes and methods. Until that happens, the MCP tools are essentially useless with the new update, and thus a particular "release" of MCP is almost always tied to a specific version of Minecraft. It is a huge volunteer effort on the part of the MCP guys to make those changes, and usually most mod developers don't start until after the MCP team has completed the deobfuscation process and release the next tool pack.

At this point I'm getting a little bit long on this post, so I'll save the direction I was going to go for the next part of this series where I'll get more into class choices and trying to figure out where to start with your mod idea you may have. Until then, I'll go ahead and plug the mod I'm developing and encourage those reading this blog to check it out and the progress I'm making so far.
Tags

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome