Tutorials/Creating a data pack

This tutorial shows how to create a data pack. Data packs were added in the 1.13 snapshot, 17w43a, but have not been released in a full version yet.

Getting Started
Note: This tutorial should take around 1 to 1.5 hours to complete.

Data packs can be used to modify command functions, loot tables, world structures, advancements, and recipes.

What not to do
There are a some things that you should not do before creating a data pack. Here is a list of "donts":
 * Do 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 .minecraft. Once you are in the folder, create a folder and name it: "Tutorial_Data_Pack". Then, open that folder.

The first thing to do after you have created the folder is to create a  file. This lets Minecraft know that the folder is a data pack.

Creating an MCMETA file
To create an MCMETA file, right click in the 'Tutorial_Resource_Pack' folder and create a new text document. Name this file “pack.mcmeta”.

Requirement
You can download Notepad++ from here:
 * Any text editor should work but the suggested is a text editor using some sort of programming IDE. Notepad++ is an excellent and free text editor, with syntax highlighting for many programming languages.

Make sure the file extension is  and not   when you rename it. You may be warned that changing a file name extension could make the file unusable. However, don't worry about that message; keep the correct file extension no matter what.
 * Note

If you can’t see file extensions, you can turn them on by going to the View menu of the file explorer and checking the check box for file name extensions.



Open  in a text editor of your choice and copy or type the following for 1.13:


 * pack.mcmeta

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 resource pack not working correctly!''' To check your files you can use a JSON validator, such as the one found on JSONLint.
 * Note

Then, make a folder called  in the folder you placed the   file. After you've done that, create a folder with your namespace. Most things in the game have a namespace, so that if both, something and a mod (or map, or whatever) are added to the game, they both act as different "somethings".

Whenever you're asked to name something, for example, a loot table, you're expected to also provide what namespace that thing comes from. If you don't specify the namespace, Minecraft, it will be  on default. This means that  and   are the same thing.

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. Basically, try not to add new things in. Namespace and other things 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 (Can't be used in namespace)

The preferred naming convention is.

Testing our Pack
Once you have created your data pack, try testing it out in game! Launch Minecraft and open the world, then type. It should say two things. One is for “vannila”, the second one should start with “/file”.

Troubleshooting
If you don’t see your pack working, make sure your is correct. If it isn't, look for any missing curly braces { }, commas, colons :, quotation marks “”, or square brackets [ ]. Remember that for each open brace, quotation, or square bracket, you must have a closing brace, quotation, or square bracket.

Adding Functions
Functions are a set of commands run by executing while playing.

To add functions, first create a folder named  inside the namespace folder. Then, create a file named. This will be your functions file. See more on the Functions page. Your function will be named in the game as.

Loot Tables
Loot tables will tell Minecraft what should be gained when a mob dies. First, create a folder named. Here is an example of a cow's loot table, it can be used for reference:

To learn what does each tag means, see Loot tables. There are also a list of loot tables at that page. Create a folder, its name should be either ,   and. "chest" is for Chest loot, "entities" is for Mob drops, and "gameplay" is only used for Fishing. After that, create your loot table with the following name:. The loot table will be named in game as.

World Structures
Structures can change how structures look in Minecraft. It is saved in an NBT format. You can create an NBT file by using Structure Block. Go to  to find your file. Then, create a folder call  inside the namespace folder. After that, paste your file with the name. Your structure can be loaded with structure blocks. It will be named as.

Advancements
Data packs also have the ability to change advancements. To do this, the first thing you need to do is create a folder named. Then, create your advancement file. See Advancements for a tutorial. The advancement file should be named as. It's name in the game will be.

Modifying Recipes
Modifying recipes is yet another function of data packs. First, create a folder named  in the namespace folder you just named. Next, create a file (with file extensions) named. means the name of the namespace. means the data value of the block or item. Mostly same with the name in the inventory, you just need to add  betweeen spaces. Special cases such as Block of Diamond is called Examples:,   etc...

Then, open the  file, and copy in the following:

1.

2.

The first recipe format is sticked recipe, which means there is a sticked position. If you change the position of the item, it will not be crafted. This means spaces are used to create blank slots in a recipe pattern. The second recipe format is shapeless recipe, which means it does not have a shape. If you change the position of the item, it will still be crafted.


 * First type

There are symbols inside, each represents a space. There are 9 items because it's 3x3. If you wanted smaller than 3x3, delete some of them. A symbol represents an item. You can change the symbol if you want to have different items. You can change the item at the space where it says. If there are two or more items, copy the following: after the first one finished. After that, type in your result, which is the same name with your json file. This is the original recipe for Piston (Can be used for reference):


 * Second type

There are no symbols inside, just the name of the needed items. So, it's very easy. Type in the names of the needed items, if there are too much items, delete one of them. If you need more, copy this and paste it at the front of the first item: After that, type in the result, which is the same name with your json file. Lastly, type in the quantity of items being created. This is the original recipe for Fire Charge (Can be used for reference):

The recipe will be named in-game as.