A .Net Developer’s Adventure in Minecraft Modding
Why Mod Minecraft
My kids love Minecraft. Actually, love is too weak a word. They are always asking me to get this mod and that skin and they are just sooo passionate about this game. They watch YouTube videos of mod developers showing off their new mods and it occurred to me that I could probably make a mod. I mean I am a software engineer. It’s just Java. Mind you, I haven’t touched Java in many years, but its object oriented programming, how different is it from C#. So, I told my kids what I wanted to do and that I would need there help and they were very excited. This gives me a chance to discover something they are into and I get to introduce them to programming… win-win. And the adventure begins.
Java Development Environment
The first order of business is to get a Java Development environment up and running. I decided on Eclipse as my IDE as it comes highly recommended and has an awesome community. Below is what I installed.
Java JDK (Java Development Kit) – I downloaded JDK 7 – http://www.oracle.com/technetwork/java/javase/downloads/index.html
Java JRE (Java Runtime Environment) – this actually came with the JDK and I already had it installed.
Eclipse – I downloaded the standard – http://www.eclipse.org/downloads/
While at it I decided to round out my Dev Rig with JUnit for testing and a private GitHub account for source control (I will open it up to the public when I have something that won’t crash and burn). You will also see later in this post that I also added a build server, Gradle, and some JAVA functional programming goodness with Scala. If I’m going to do this I’m going all out.
Minecraft Loader
The Minecraft loader is the program that launches the Minecraft game. You purchase the loader on minecraft.net.
Minecraft Forge
Minecraft Forge is a Minecraft Mod Loader and API. As I understand it right now, it is a wrapper around the official Minecraft game that allows you to load mods (modifications). Forge provides a simplified API for working with the Minecraft source code to make mods. The Forge Mod Loader allows you to load mods made with the Forge API.
I decided on Minecraft Forge as it seemed to have a good community. I wanted to use something called MCP, which from what I understand, Forge actually uses MCP for decompilation of the Minecraft source. Although, I also read that Forge is working on their own decompiler. I didn’t use MCP because I got frustrated as I am a noob and couldn’t figure some things out in the install process. Plus, the kids tell me that Forge has the cool mods.
Anyway you download the latest version of Forge for your version of Minecraft, but I was told by a community member that version 1.6.4 had the most mods at the time I wrote this. Minecraft.exe currently defaults the game version to 1.7.4 and Forge is at 1.7.2 and this gave me the biggest headache trying to get the two to work together until I figured out you can edit your Minecraft profile in the loader and select the version you want to play (this would have fixed my MCP issue too). So let’s get Minecraft 1.6.4 working with Forge 1.6.4. So here is how I got the Forge loader working:
- Launch Minecraft
- Update profile to use the 1.6.4 version and save it
- Click the Play button (this sets up the 1.6.4 files that are needed for Forge)
- Then download the recommended Forge 1.6.4 installer from http://files.minecraftforge.net/
- Run the installer
- Click windows start key plus R to open the run dialog and type %appdata% and click OK (you can also type this in Windows explorer)
- Open .minecraft folder, this holds all of the Minecraft assests
- Open the version folder
- Open the Forge folder for the Forge version you downloaded and copy the two files
- Go back to the version folder and create a new folder and name it whatever you want (remember this name you will need it)
- Open the folder and paste the files you copied
- Rename both files to the same name you used for the folder
- Open the file with extension .json and find the ID field and change it to the name you used for the folder and save
- Launch Minecraft
- Update profile to use the version that matches the name of the new version folder and save it
- Click the Play button
- You will be running the new Forge mod loader you just installed and you can add new Forge based mods to it by copying the mod zip files to the mod folder in the .minecraft folder (make sure your mods match the version you are running or it will crash and burn)
Mod Development Setup
Now we will continue with our Development Environment setup to get it ready for mod development.
- Download the recommended Forge 1.6.4 src from http://files.minecraftforge.net/ (you can get whatever version of Minecraft you want to develop for)
- Extract the zip to a folder any where you want
- Then open the folder and run the install.cmd
- After the install completes, open Eclipse
- Select a workspace by browsing to your Forge install, mcp/eclipse folder and click OK
This will import the Minecraft source code into the IDE and you can get to work modding your Minecraft world.The install took awhile so you can take a break when you start the install.
Other Goodies
Scala
During the Forge install I noticed in the command window that it is working with MCP and it does a lot of decompiling, updating, and recompiling of the Mincecraft source code. I also noticed a message: “scalac” is not found on the PATH. Scala files will not be recompiled. I am not sure if I will need to use Scala, but I always wanted to use Scala so this is a good a time as any to get it set up in my Java Environment. I downloaded the Scala installer from http://www.scala-lang.org/ and I allowed the setup to update my system path variables. I didn’t feel like reruning the Forge installer so hopefully I won’t need the recompiled Scala files for basic learning.
Gradle
In earlier versions of Forge you had to use the Gradle Build Server to setup your source code and Eclipse for development. Even though it isn’t necessary in the version I am using I still setup Gradle because it seems very cool, well Geek Cool. I really need to look into Gradle more for my .Net environment as they have some very interesting concepts for build environments. Anyway, you can install Gradle from http://www.gradle.org/downloads. You can just unzip to some location on your machine. Then copy the path to the Gradle bin folder and add it to your system path environment variable. That’s it, you have a Java build server.
Minecraft Server
I want to host our mods in our own Minecraft server, but I ran into the version issue again. I have 1.7.4 server, but my mods will be 1.6.4. Well with a little URL hacking you can download the 1.6.4 version of the server from the Minecraft download server. This is the same server jar URL as the latest release, I just change the release from 1.7.4 to 1.6.4. https://s3.amazonaws.com/Minecraft.Download/versions/1.6.4/minecraft_server.1.6.4.jar
Conlusion
That’s if for now, I will try to post some of my modding experience later. I am in a very strange land, but I think it will be great doing something both constructive and fun with my kids.
I really love your idea! Looking forward to hear some progress 🙂
Unfortunately, my kids lost interest. Something about them wanting to have fun playing the game not making the game. Guess me trying to coax them into programming will have to take another approach. Maybe Lego Mindstorms, looks like fun to me, then I thought modding Minecraft was fun.