Minetest Cereal, Week 3: Inverted World

Blocks aren't nodes

Invented World

The tools to convert back and forth between the Minetest world format and my Minetest Cereal format are past the first hurdle. They can convert to and from a database that uses x,y,z coordinates for block positions and back.

On a lark, I converted my "DemoLand" world into an MTC and reversed the x,y,z coordinates of every block before converting back. I expected to find that the world would be upside-down and backward, with the ground hanging in the sky and trees standing on their leaves.

Not quite what happened. Turns out I missed the note that each block represents a 16x16x16 cube of nodes. You can see in the picture that on a large scale, things got reversed. Caves and stones occupy the sky, things that were East are now West. But on the small scale, up is still up, left is still left, etc. Each of the corners of the house I built is in an opposite position relative to the others, the front is behind the back, left is now right; but within their local space the corners themselves hold their normal shape.

So I missed that detail, but the tools still work and you can start to see how making the format human-readable would lend itself to more creative database play.

Don't skip your tests

You can't really run unit tests on data that is inconsistent, especially if you don't understand it. For this reason I skipped writing the tests for the parts of the converters that worked directly on the database.

That turned out to be a bad move - it took me a lot longer to finish the development and it was much harder to debug each of the parts. I've had many conversations with other developers explaining this phenomenon, but this is the first time I've been able to confirm it for myself. There are research studies about this, I don't know why I thought this instance would be the exception.

Next

The next bit looks trickier. I'll need to actually parse out the binary blobs representing the blocks. Since each block is actually 16x16x16 nodes, plus a bunch of other data, I imagine there will be several rounds of iteration between understanding a piece and representing it well.

On the upside: the map generator is capable of creating "single node" (all air) worlds, so setting up a clean Minetest world to run unit tests against should be relatively simple.