Over the summer, I decided to go for a side project, namely finally do something that renders from data. And I think I’ve achieved that.

Prototype n.o. 2

Prototype n.o. 1

Effectively, I made two different prototypes. The one on the top is one generating vector images (or so intended, it does generate SVGs with PNG backgrounds for terrain tiles), whilst the one below is intended for large-scale maps and renders 1 pixel per block. Both share some code, but the vector one is perhaps better refined in internal tech (e.g. uses Cobra, Viper, Zerolog, all of which have proven highly useful)

Here’s what I learnt:

  • Minecraft data format is complex to say the least. A fair number of corner cases were hit (e.g. entities are stored separately from blocks, blocks may be waterlogged). However, nothing was really impossible
  • Related to above, data normalization is a must. MC chunk files have compated data storage formats, which aren’t really amenable for easily readable analysis code - a fairly significant amount of time was devoted to devising mechanisms to extract this data into easier-to-process forms.
  • For above, Golang’s reflection is super useful - what luxurious convenience it is to convert NBT fluently into structs! (thanks to tnze’s NBT package, which I studied and followed its example to adapt it to my needs)
  • There’s a definite need for automatic parsing of resource packages - there are so many different blocks that for 100% accuracy, this is effectively an imperative need. You get only so far with heuristics.
  • For above, good test cases are important to ensure your code works as you intend it to with known cases. I need to make them stricter next time.
  • With suitable design, one can do a whole lot to parallelize the action. Pretty much all steps of processing (reading, possible transformation steps, rendering) can be done in parallel, and for that, Go made it super easy. I’ll use it next time too.

As I’ve worked pretty intensely on these for the past month with what time I had after work, I feel like a break on this now - both are working prototypes, and stored safely in a backed-up Git repo. No plans to publish it yet, but if there’s a demand for it, send a word my way and I’ll push the priority up for a source code release by least.


© Arttu Ylä-Sahra 2016-2021
Page rendered on 2021-08-30T00:16:54.098+00:00