Move MapBlock (de)serializing code out of Database class

**Backup your worlds before trying this**
This also fixes #1340
Inconsistent code blocks.  Use `{}` for all or no blocks in a `if`/`else if`/`else` set.