How to replace blocks and items in Minecraft .mca files?
Solution 1:
One of the most common tools for editing Minecraft files is NBT Explorer.
It doesn't do what you need, but since you mentioned you can program it yourself here are some pointers:
The .mca
file format is called Anvil file format and is based on Region file format with changes to the chunk format. The description in the wiki is not very friendly but basically, to read anvil files:
- Follow Region file format until you get the chunk blobs.
- Once you decompress the blob, it is in Named Binary Tag format which is a generic binary format.
- Once you can parse the NBT tags, consult Chunk format to interpret the chunk data.
NBT Explorer is open source, so you'll be able to borrow some code from there, specifically this part seems to be concerned with the actual parsing and interpreting of the data.
Solution 2:
If manually going through NBT Data is not your thing, you can use editors such as:
- MCEdit
- WorldEdit (Forge Sponge/Bukkit/Spigot)
And mass-editing the world in-game instead. There's also the /fill
command.
Edit: This may be what you're looking for