Editing Minecraft Worlds in the browser

Demo available here: block-switch.com

Updating Modded Minecraft Servers Link to heading

There are many different versions of Minecraft, and many more mods. Some mods support multiple versions and are quite quickly updated by the developers to support a new version of Minecraft when the game is updated. Others, especially the more complicated mods, take much longer. Of course some become abandoned by their developers also.

This means that whenever we want to update our modded Minecraft server to a new version of the game, we also have to wait for the mod developers to update the mods we’re using. Sometimes this isn’t possible, and we have to remove some mods. If the mod added new blocks to our world, any blocks in the world will be removed. For example, if we’ve created a build using a block from biomesofplenty such as biomesofplenty:amber_block and then we remove the mod, this block will disappear along with all the other blocks added by biomesofplenty.

To prevent this from happening when I updated my modded NeoForge Minecraft server. I wanted to replace blocks that would otherwise be deleted with a suitable alternative; There are tools such as WorldEdit or Amulet Editor that can be used to edit Minecraft worlds. But I wanted the ability to simply specify a mapping of blocks from one type to another and then update every single chunk!

Requirements Link to heading

  • Simple intuitive configuration file for mapping. (JSON)
  • All processing should be client side, no uploading / downloading of data.

Approach Link to heading

First, I decided on a simple set of rules that could be used map old blocks to new blocks:

  • Prefix matching rules - As minecraft blocks follow the naming convention modname:block_name this allows easily targeting all blocks in one mod such as ae2: for all blocks in Applied Energetics 2.
  • Individual block matching rules, these rules take precedent over the prefix matching rules, similar to the specificity rules of CSS.

Using both these rules, we can use ‘Prefix Matching’ rules to do large groups of blocks at a time and then use the ‘Individual’ block matching rules to fine tune as necessary.

While researching the Minecraft region format Anvil I discovered fastanvil—A Rust library. I hadn’t really used Rust before this, but I knew that I could easily compile to WebAssembly so this seemed like a good opportunity to try it out!

For updating files locally on the user’s PC from the browser, I needed decided to use the ‘File System Access API’. This is supported on Chromium-based browsers but unfortunately not Firefox. So despite being a Firefox user myself, it’s necessary to use a different browser to be able to use the tool.

Results Link to heading

I’m quite pleased with the results, I’ve processed some large maps successfully, and I didn’t have to wait very long. As well as meeting my requirements for replacing blocks from specific mods with blocks from comparable mods; I’ve realized that it can also be used to create some interesting effects in a world, such as replacing all water blocks with lava. I can see some potential for this tool when creating challenge maps.