A Grownup's Guide to Minecraft and Writing Minecraft Mods

Minecraft is a good-natured indie game that's like a cross between Lego, Doom, and Second Life, but with chickens, pigs, and zombies. Its graphics are enthusiastically low quality - kind of like South Park's, but blockier - and in exchange for the low quality, the world is totally editable in-game. It's all the rage among boys 9 and up.

To get a feel for it, watch the trailer, the official four part beginner's tutorial, a third-party tutorial, and a few pop song parodies based on the game. (Teachers, see the "Teaching Minecraft" video series from MinecraftEdu, or the links at GamingEdus.org.)

Installing Minecraft

If you haven't already, buy a minecraft account, download the launcher, and install it.

If you use Linux, the launcher you want is Minecraft.jar. Install java (e.g. 'sudo apt-get install openjdk-7-jre'), then run the launcher (e.g. 'java -jar Minecraft.jar'). This will download and install Minecraft proper into your ~/.minecraft folder. It's how you will always launch minecraft. (See also the Minecraftwiki FAQ.)

Learning Minecraft Basics

Beyond the tutorials linked above, MinecraftWiki has quite a few tutorials. Look over that page, read the first few, and then come back later when you need to know more. And surf Youtube for Minecraft walkthroughs / Let's Play / Yogscast videos. There are literally thousands of these, in every language (e.g. German).

Saved Games / Worlds / Maps

As with many other games, you can save your progress when you quit. But since Minecraft lets you edit the world, these saved games are really saved worlds. People often create intricate worlds and upload them for others to play in; one site that catalogs them is MinecraftMaps.com; they are also listed somewhat chaotically on the Minecraft Forum's Maps subforum. To install a downloaded world, just unzip it into ~/.minecraft/saves; see Minecraftwiki's Map downloads tutorial.

Resource Packs

Some worlds require a Resource Pack. That's just a set of alternate sounds or images for a world. Minecraft 1.6.2 makes it really easy to install them - you just copy the .zip file into the resourcepacks subfolder of ~/.minecraft without even unpacking it.

One map that requires a resource pack is Mysterious East. (See the yogscast video for some idea of how to play it once you have the save unpacked and the resource pack downloaded.) Give it a try.

Mods

Resource packs are great for changing the look of a world, but to change the behavior of a world, you need to write some Java, or at least edit some JSON files. Minecraft is relatively easy to hack on, so there are lots of fan-written code changes (called 'Mods').

Unfortunately, there is no authoritative source for mods, though there are a few lists, at e.g. minecraftforum.net, planetminecraft.com, and minecraftwiki.net. People seem to just find out about a mod and google it or search for it on youtube.

Installation methods used to vary wildly, and incompatibility was rife, but these days, most mods are compatible with MinecraftForge, a convenient mod loader.

Installing MinecraftForge

This used to be hard, but recently they had a genius idea: create a simple installer. (Amazing!) See any of the many tutorials for tips on how to download and run the installer.

Once you have it installed, to install a mod, you download it to the ~/.minecraft/mods folder, and then start Minecraft, choosing the Forge profile; installed mods are always active.

See my Using Mods page for semi-detailed instructions for how to install a couple interesting mods on Windows, Mac, and Linux.

Creating Mods

Your child will probably happily play with mods for many months... but eventually will want to create one. This is hard, and you'll have to help, at least to get started.

The original way to create mods was to install the Minecraft Coder Pack. I've done this, and successfully created a trivial mod with it, but it's probably not where you should start.

MinecraftForge Source

MinecraftForge has a lesser-known side: it provides a mod development environment, which includes a copy of MCP under the hood.

To install it, see MinecraftForge's Installation/Source page.

Unzip it, cd to the forge directory it creates and run python install.py. This will take ten or so minutes on a fast machine. If it complains about hunks of patches not applying, try it again after installing the prerequisites listed on the page linked above (e.g. "sudo apt-get install wine astyle").

Minecraftforge has a very scary tutorial, and wuppygaming has even more.

Java programming?

These tutorials are probably hard to follow if you don't know at least some Java programming. Once you have each tutorial working, though, it's easy to tweak things like item names and strengths without knowing much or any Java.

There are an infinite number of Java tutorials out there, for instance:

Hello, Minecraft Mod

The Basic Modding looks scary, but if you've ever programmed Java, it's really not bad, it takes about 15 minutes. Follow that and then the Basic Items tutorial, and press 'Play' in Eclipse.

To get one of the items you created in your mod, start a world in creative mode, then press 'e', click on the rightmost tab of your inventory, and scroll to the bottom; you should see it on the bottom right. Drag that to the bottom row of the inventory window, and press escape; then press the number for the slot the item is in. Voila, you're wielding it.

The Missing Food Tutorial

There wasn't a tutorial for Basic Food, but that wasn't too hard to figure out; in Generic.java, add an import near the top:
import net.minecraft.item.ItemFood;
an item in the class:
private final static Item genericFood = new ItemFood(5002, 5, 5,
false).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("genericFood");
and give it a name in the load() method:
LanguageRegistry.addName(genericFood, "Generic Food");
Now to try eating your food, press Play, wield the new item as above, then switch to survival mode (/gamemode 0), run around until you get hungry (the wine glasses on the lower right of the HUD will start emptying), then right click and hold. You should now be messily eating the food you were holding, and your hunger should go down.

Making your items look good

The above instructions leave your items looking like checkered test patterns, so let's make them look like something more interesting.

First, tell eclipse you're going to add textures for your mod. Right-click on src in Project Explorer, pick New / Package, and name it, say, assets.generic.textures.items. This will jog eclipse into creating a directory forget/mcp/src/minecraft/assets/generic/textures/item.

Then use your favorite paint program to create a 16x16 image, and save it as file foo.png in that folder.

Finally, in your Generic.java, in the constructor for Generic where you have a line like

private final static Item genericFood = 
  new ItemFood(5002, 5, 5, false)
        .setCreativeTab(CreativeTabs.tabMisc)
        .setUnlocalizedName("genericFood")
        ;
tack on .func_111206_d("generic:Qu") to the end, before the semicolon. e.g.
private final static Item genericFood = 
  new ItemFood(5002, 5, 5, false)
        .setCreativeTab(CreativeTabs.tabMisc)
        .setUnlocalizedName("genericFood")
        .func_111206_d("generic:foo")
        ;
(Why func_111206_d? Well, minecraft wasn't quite designed for modding, and the name for the function that sets textures got optimized away; and the best mcp could come up with as a replacement name is a random string of digits.)

Press the 'Run' button, and you should now see your genericFood item looks less boring in your inventory and when you drop it!

See also the minecraftforge texture tutorial.

Further reading


Copyright 2013, Dan Kegel
Back to kegel.com