I have to admit, I’m a big fan of Minecraft for a while now, and I love the way the creators, Markus and Jens, are very open about working on this game. When Minecraft 1.3 came out it had a new way of saving the huge and worlds. If you take a quick look at the wiki you’ll notice that there’s a lot of information for developers to work with the Minecraft data format. I was very curious about what I could do with the level data. A few weeks ago I created a small tool in Java that works with the level format, and learned quite a lot about the way Minecraft stores the world.
But since I love to work with ActionScript, I was wondering if I could do something with the level files in Flash or Air. I thought that with the ByteArray and BitmapData class available, I should be able to do fun things. So I started working on a simple map renderer. As far as I know, Flash doesn’t support reading directories, so I Air was my platform of choise.
I ported the JNBT library to ActionScript to read the binary format of the ‘chunks’ (16 x 16 x 128 blocks) that Minecraft uses to store the world in. The rest of the code is rather quick and dirty. Pretty much everything was hardcoded into a few loops to render the blocks to individual BitmapData objects. This is the result:
Edit: I got a few requests for the sourcecode. So with no further ado: here it is! You’ll need to compile ‘MapRendererMain‘ as an Air application. Included is my ActionScript port of the JNBT library, found in org.asnbt. You can use this library to read and write NBT files. The most important classes besides the JNBT library are the ‘SimpleRegionFile’ class and the ‘RegionBitmapData’ class. Feel free to fool around and let me know what you think!
Edit 2: There was an update to the world format a few weeks ago, making this tool useless. Only MCRegion worlds are supported. the AS3 NBT classes still work though!