If you have children of a certain age, or are a child at heart yourself, you have probably come across Minecraft, a wonderful game that proves that gameplay and creativity can still trump fancy graphics, explosions, and photoreal environments.
Minecraft is all about building things, but you build in the game, using only the tools that the game’s creator gives you. After having mastered the game from the inside, my sons wanted to see the matrix. They wanted to know how it worked, and change it, and come up with their own tools and their own rules. So, after poking around a bit, I discovered that Minecraft is written in Java, and there is a huge community of people who mod the game. But Java is not the best language to teach my 9 year old, so a bit more digging brought me to this awesome project by one the JRuby guys, Purugin. This lets you program Minecraft using Ruby, which sounds like a whole lot of fun, so let’s get started.
(These instructions assume you are on OSX. The same ideas should translate over to Windows as well.)
First, go to Minecraft and download (and purchase) the desktop client, and get that working on its own.
Next, we need to get the CraftBukkit server, which will hold our world and our custom code, and we will eventually connect our clients to this server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Now, let’s start the server:
You should see the server start up. Make sure you see lines like this in the output, which indicate that the JRuby plugins loaded OK:
1 2 3 4 5 6 7
At this point, you can run the Minecraft client App, and say Multiplayer –> Direct Connect to localhost, and you should connect to our server.
As you are playing Minecraft, you can issue commands by typing
/, so lets try our first command by typing this in the Minecraft client:
This will create a 5-block cube in front of you. The code that made that happen is here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
.rb file you put in the
~/Code/CraftBukkit/plugins directory, will be automatically picked up and available for you to call.
So, that’s great, and it’s Ruby, which is a bit nicer (IMHO) than Java, however it’s still a bit beyond my 9-year-old son. Luckily, there is also a simple Logo implementation available to us, so that in Minecraft we can type
and you should see a chicken drawing a tower in front of you. The code that does this, is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Ahh, a much nicer syntax for a child to grasp, and they can see their creation come to life in front of them, which is highly motivating.
.rb file (written in the Logo-ish syntax) you put in
~/Code/CraftBukkit/plugins/purogo will be available to call with the
So, we have barely scatched the surface of what can be done, but it is wonderful to see a child’s eyes light up the first time they “hack the matrix” and write code that creates something they can actually see in the Minecraft world. Many thanks to Tom Enebo for creating Purugin, and hopefully sparking an interest in programming in our children.