IVAN STANTON

Computer Nerd

Modding Minecraft with Datapacks

Minecraft is either the first or second best-selling game of all time, depending on whether Tetris is one game or not. I played it quite some time ago, and have since decided to return to playing the game. I discovered that there were some new updates that were quite interesting.

In update 1.13, Minecraft released a new feature called datapacks. These allowed players to customize the following:

A long time ago, Mojang AB announced the development of a "Minecraft API" which would allow players to modify the game, and this is basically it. Until now, modifying crafting recipes would have been impossible normally.

Of course, you can't make an API without programming, so let's look into that.

JSON

JSON (Javascript Object Notation) is a data-interchange format designed to be easy to parse, generate, read, and write. Minecraft also uses JSON for metadata about its versions and resource packs, so it is natural that JSON would be used for data notation in mods. A JSON file for a recipe might look something like this:

   {
       "type": "crafting_shaped",
       "pattern": [
           "TTT",
           "#X#",
           "#R#"
       ],
       "key": {
           "R": {
               "item": "minecraft:redstone"
           },
           "#": {
               "item": "minecraft:cobblestone"
           },
           "T": {
               "tag": "minecraft:planks"
           },
           "X": {
               "item": "minecraft:iron_ingot"
           }
       },
       "result": {
           "item": "minecraft:piston"
       }
   }

This says the following:

Where's the programming?

Minecraft has had an in-game console for some time that allows players to interact with the in-game world in numerous ways, so in essence, all of the programming is done in scripting a sequence of commands. Prior to the 1.13 update, someone had gone as far as to make an Atari emulator using commands, so it's fair to say they're versatile enough. I still wish there was more to do with them, though.

Atari 2600 in Minecraft

So those are datapacks, in a nutshell. I hope this feature evolves into a full plugin API. In the meantime, check out something I created with datapacks.