Thursday, August 25, 2011

[minecraft] That's right, I said Minecraft...

A couple weeks ago I decided I wanted to practice my Java coding. I looked around for possible Java projects, and I came across Minecraft modding. Writing a mod seemed like a great project because it would be fun and easy to get started (thanks to the modding community being very friendly and active).

There are two kinds of mods: single player and multiplayer. Single player mods can do neat things like add items and monsters to the game. Multiplayer mods are a slightly more restricted because only the server code is modified and the mods can't do anything the original client can't handle. I chose to create a multiplayer mod because I also wanted to run a server for my friends.

For multiplayer mods there is an unofficial extension framework called Bukkit. Bukkit is split into two pieces of software. Bukkit proper is an API programmers use to write their plugins. Craftbukkit is a modified server with plugin management. If you want to write a plugin, you want Bukkit. If you want to run a server with plugins, you want CraftBukkit. The Bukkit API is changing all the time, so the best documentation is the source, but I've also found these java docs to be useful.

My plugin is called HealingTotem. It allows players to regenerate health if they are in the proximity of a Totem. The concept is simple, but the design had some interesting twists. As far as I know, this is the only plugin which searches for configurable block patterns. Users can define block patterns, or structures, as a list of blocks with a relative offsets and material types. My plugin efficiently searches for structures as blocks are created and destroyed. Typically, other plugins require the use to enter a command to perform a check, or "activate" the structure by using an item on a block. As a bonus, my plugin searches for structures at different orientations.

I might write some more Minecraft modding related posts later, but for now I just wanted to share my work, so here it is:

HealingTotem - Health Regeneration from Totem Poles (source)