Skip to content

Datapack Tutorial

Noaaan edited this page Oct 27, 2021 · 8 revisions

Knowing how to create a datapack is essential when creating new Alloy Forge recipes. If you already know how to create a basic datapack you can start making recipes [WIP, INSERT LINK HERE].

Creating a Datapack

Creating a basic datapack is fairly simple. To start out you need a folder or a zip file that contains the datapack.
The main components for the datapack are:

  • A pack.mcmeta file, which tells Minecraft what versions your datapack supports.
  • A data folder, which contains all the data of your pack.

These are found in any data pack, and you can look at any datapack for these. This tutorial will teach you how to format these.

At any point where JSON is used, using a JSON checker like JSONLint is useful for catching bad formatting, especially comma errors.

The pack.mcmeta file

A .mcmeta file is just a JSON file with a custom extension. The file usually looks something like this:

{
  "pack": {
    "pack_format": 7,
    "description": "Put your description here"
  }
} 

The pack_format file determines what versions of Minecraft your datapack supports. You can still load outdated packs, but the game warns you about loading outdated them.

To create this file you can simply save/edit a text file with the .mcmeta extension.

Currently for 1.17+ the pack format is 7.
For future versions of Minecraft this can change, and the best page to find the latest number is on the Minecraft Wiki.

If you are struggling with creating the file, you can simply copy a mcmeta from ANY datapack. It's not stealing.

The data folder

The data folder frankly contains all your data files. When putting data inside you separate it using folders. The first folder you create is a namespace.

A namespace is a core/root folder, which prevents conflicts with data from other places.
The standard structure for your pack would be data/namespace, and in this folder you put your data.

Having limitless possibility can cause some confusion between packs, which is why Minecraft only loads specific things from specific folders. An example is the fact that recipes will only be loaded under a recipes folder. A list of folders that work this way are:

  • advancements
  • dimensions
  • functions
  • loot_tables
  • predicates
  • recipes <--- This one is the most important for Alloy Forging
  • structures
  • tags
  • worldgen

When putting files inside these main folders but you can create subfolders to sort it as you please.
Note that every file and folder inside the data folder MUST BE LOWERCASE.

Example Datapack

Now to try to create a datapack!
To get started we will do the following:

  • Create a new single player world (with cheats enabled)
  • Exit back to the meny
  • Navigate to the world we created
  • Click "Edit World"
  • Finally, click "Open World Folder".

Then we will head into the datapacks folder, where we can create our datapack.
Note that when we are done with this we can turn this folder into a zip file, and then install it on other worlds/servers.

First we will create the pack folder, which can be named anything you please. For this example we will call it "TestPack".
Inside we create a pack.mcmeta file, and an empty data folder. Since I am playing on 1.17.1 I set the pack_format to 7.
Then I open the world again [WIP]

Clone this wiki locally