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:
If you want to give it a spin, you can download the .air file here!
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!
this is awesome! any chance you will release the code?
I’m not sure what the license is of the JNBT project. If the license permits it, I can release the source code. I will take a look at this when I’ve got the time!
Edit: JNBT has a BSD license. So I should be able to release the ActionScript port, right? (I’m not really familiar with all the licenses)
Yeah, I think BSD is pretty permissive, you can even use it in proprietary software I think.
Would you like me to mail you when I update the article with sourcecode?
Pingback: Cool Stuff with the Flash Platform - 10/24/2011 | Remote Synthesis