Terrain generator

Added a bunch of optimizations and restructuring to the map generation. Caves are hard, so that will be a problem solved another day.
I'd rather not do a dump-import like this. It seems like the only reason we really use it is to avoid having to prefix the BLOCK_* symbols with `mapgen.`, but I'm not sure that's a compelling enough reason to lose the information about where the symbols are coming from.