After spending a bit over three months at LShift, I am proud to leave LShift’sÂ mark in the Minecraft Universe.
Frolicking over Minecraft’s cubic pastures and passing by interesting arrangements of hovering dirt blocks suspended in mid-air is all in a Minecrafter’s day’s work. But if you ever see light-blue wool blocks hanging around in the air, you can be sure that someone’s been . . .Â Shifty . . .
The ones you see in the picture above, in fact, have been put into the Minecraft world by a tool I wrote in Haskell. In this multi-part series, I want to share with you how I did it.
What does it take to carry an idea from conception to realisation in Haskell?
And here are the requirements I worked with. The task is to write a Haskell program that takes
and then it
Simple? Not quite. As with any software projectÂ â€” even one as small as thisÂ â€” the devil is in the details. The Minecraft saved game format turns out to have an interesting structure involving offsets, some compression and even some odd (even some odd? :/) Â ’nybble endianness’ in places.
In case you are wondering, there are already many really good libraries for editing and manipulating Minecraft saved worlds (and no, I’mÂ notÂ talking about the diamond axe), so the concept of my toolÂ is nothing new.
To use those tools directly for my aims presents little challenge. Being a bit of a Haskell enthusiast, this project presented itself as a fun way to try Haskell out for size on problems resembling those you see in the real-world, such as dealing with and manipulating binary data.
Throughout the series, I aim to uncover details as we require them, just as I did while I explored the problem space. At a glance:
I must admit I didn’t actually practise TDD, but the way I went about it actually more in line with the strong-typing mantra:
If it compiles, your code’s probably doing something useful.
Though whenever I found that my code didn’t work immediately after making it compile, the fall-back is simply to write some tests to help debug the problem.
And that, dear reader, is the principal matter of the next post. I hope you’ll enjoy it!