Tutorials/Creating a data pack

This tutorial shows how to create a data pack.

Getting started
Data packs can be used to add or modify functions, loot tables, world structures, advancements, recipes, and tags.

What not to do
There are some things that you should not do before creating a data pack. Here is a list of "don'ts":
 * Anything that violates Mojang's terms of use for Minecraft.
 * Release Minecraft versions or modifications that allow players to play without having bought Minecraft from Mojang.
 * Release the decompiled source code of Minecraft in any way.

Creating a data pack
To create a data pack, start off by navigating to the  folder inside the world folder.

To find the world folder, locate the  folder inside your game directory, which is .minecraft by default.
 * In singleplayer, you can select your world, click on "Edit", then "Open world folder".
 * On a server, you can navigate to its root directory (where server.properties is located), then enter the  directory.

Once you are in the  folder, create a folder with a name of your choice. It will be your data pack's name. Enter the data pack folder.

The first thing to do after you are in the folder is to create a  file. This lets Minecraft identify your data pack.

Creating an MCMETA file
To create an MCMETA file, right click within your data pack folder and create a new text document. Name this file "pack.mcmeta".

Make sure the file extension is  and not   when you rename it! In other words, remove your old file extension. You may be warned that changing a file name extension could make the file unusable. However, this actually indicates that you have renamed the  file correctly.
 * Note

If you are using Microsoft Windows and can't see file extensions, for Windows 10, you can turn them on by going to the View menu of the file explorer and checking the check box for file name extensions. For Windows beneath Windows 10, you can uncheck "hide extensions" in folder settings.



Text editor
Any text editor should work. It is recommended that the chosen text editor supports JSON, which is the format used by files of  extension and most other files in a data pack. Note that most text editors do not recognize  extension as JSON. Thus, you need to configure the editors manually.

content
Open  in your text editor and paste or type the following: In , it is possible to use the § symbol(Minecraft Formatting codes) in the description of   and the datapack name.

The should be set to 5, if the data pack is used in 1.15 or above. The can be any string or a raw JSON text. It will show up when you hover over your data pack in the output from.

This file is written in JSON! This tutorial does not go into specifics about the format now, but be aware about how things are laid out. '''Be very careful not to forget quotation marks, colons, and curly or square brackets. Missing one of these can lead to your data pack not working correctly!''' To check your files you can use a JSON validator, such as the one found on JSONLint.
 * Note

Testing your Pack
Once you have created your, try testing it out in-game! Open the world or, if you are already in the world, type, then type. It should list two entries. One should be, the second one should be named like  , where your data pack's folder name goes at. When you hover over your data pack's entry, you should see the description of your data pack as you have written in of your.

When your pack shows up, you are ready to move on.

Troubleshooting
If you don't see your pack in the list, make sure your  file is correct. Look for any missing curly brackets {}, commas ,, colons :, quotation marks "", or square brackets []. Remember that for each open brace, quotation, or square bracket, you must have a closing bracket, quotation, or square brackets.

Naming
Make a folder called  in your data pack folder, where you have placed the   file in. In this  folder you have to create another folder which will act as your namespace.

Entries in data packs have namespaced IDs in a fashion of. The corresponding file would be located at. Note that  characters in the path will be translated into directory separators.

A few examples:
 * an item tag of ID  would be located at
 * a function of ID  would be located at

Legal characters
Namespaces, paths and other folder and file names in the data pack should only contain the following symbols:


 * Numbers
 * Lowercase letters
 * Underscore
 * Hyphen/minus
 * Forward Slash/Directory separator (Can't be used in namespace)
 * Period

The preferred naming convention is, called lower snake case.

Namespace
Most objects in the game have a namespaced ID to prevent potential content conflicts or unintentional overrides.

For example, if two data packs add two new minigame mechanisms to Minecraft and both have a function named. Without namespaces, these two functions would clash and the minigames would be broken. But if they have different namespaces of  and , the functions would become   and  , which no longer conflict.

Most of the time when Minecraft requires an ID, such as for, you should provide the namespace in addition to the path. If you don't specify the namespace, it will fallback to.

Make sure to always use your own namespace for anything new that you add, and only use other namespaces if you're explicitly overriding something else, or, in the case of tags, appending to something else.

For example, Minecraft uses the  namespace, which means that this namespace should only be used when the data pack needs to overwrite existing Minecraft data or to add its entries to vanilla tags.

Functions
Functions are a set of commands that can be run in order.

To add functions, first create a folder named  inside the namespace folder. Then, create a file named  in this folder or in any of its subfolders. This will be your function file. Your function will be named in the game as  or   when the function file is located in a subfolder.

Loot tables
Loot tables will tell Minecraft what should be dropped when a mob dies or what should be generated inside containers, like chests, when opened for the first time.

To add loot tables, first create a folder named  inside the namespace folder. Then, create a file named  in this folder or in any of its subfolders. This will be your loot table file. Your loot table will be named in the game as  or   if the file is located in a subfolder.

Here is an example of a cow's loot table, it can be used as a reference:

To learn what each tag means, see Loot tables. There are also a list of vanilla loot tables on that page.

Structures
Structures can be used with structure blocks and jigsaw blocks and/or can overwrite how certain vanilla structures look in Minecraft. It is saved in an NBT format. You can create an NBT file by using a structure block or by exporting a build using a third party program like MCEdit.

To add structures to a data pack, first create a folder named  inside the namespace folder. Then, put your structure file in this folder or in any of its subfolders. Your structure will be named in the game as  or   if the file is located in a subfolder.

Advancements
Advancements can be completed by players and give various rewards.

To add advancements, first create a folder named  inside the namespace folder. Then, create a file named  (You can't put spaces in the file name. Use lowercase letters in the file name). in this folder or in any of its subfolders. This will be your advancement file. Your advancement will be named in the game as  or   if the file is located in a subfolder.

Recipes
Recipes are used to let players craft items.

To add recipes, first create a folder named  inside the namespace folder. Then, create a file named  in this folder or in any of its subfolders. This will be your recipe file. Your recipe will be named in the game as  or   if the file is located in a subfolder.

Shaped crafting
The first common type of crafting is shaped crafting. This is a rough example of a shaped crafting recipe, as specified by the  type. is a list used to specify the shape of the crafting recipe. It contains a maximum of 3 strings, each string standing for one row in the crafting grid. These strings then contain a maximum of 3 single characters next to each other, each character standing for one spot in the crafting grid. You don't need all 3 strings, nor do you need to have 3 characters in each string. But each string should contain the same amount of characters. You can use spaces to indicate empty spots.

is a compound used to specify what item should be used for which character in. This can either be specified using  followed by an item ID or   followed by an item datapack tag.

The  compound speaks for itself, it specified what the resulting item should be. is used to specify how many of the item should be given.

This is the original recipe for a piston (can be used as a reference):

Shapeless crafting
There's another common type of recipes, a shapeless recipe. As specified by the  type, this is a recipe without a. The  can be put in the crafting grid in any shape or form. In the example, there's a list inside the  compound. This means any of the items in this list can be used.

This is the original recipe for Fire Charge (can be used as a reference): Smelting

It is also possible to create new smelting recipes. This is a rough example of a smelting recipie. "ingredient" is used to specify the item you are going to smelt. "result" is going to specify the result. In "experience", you are able to choose the amount of xp gained for smelting, and in "cookingtime" the amount of time that it will take for the item to smelt, which in this case is 10 seconds (200 ticks = 10 seconds).

This is the default smelting recipie for a diamond ore:

Tags
Tags are used to group blocks, items, or functions together. Additionally, the  function tag is used to run functions every tick and the   function tag is used to run functions every time the world is (re)loaded.

To add tags, first create a folder named  inside the namespace folder. Inside this folder, create folders named,   and. Then, create a file named  in one of these folders or in any of their subfolders. This will be your tag file. Your tag will be named in the game as  or   if the file is located in a subfolder.