Tutorials/Creating a data pack

Time Required
This tutorial should take around 1 to 1.5 hours to complete.]

Getting Started
First off, let's start off small. Data packs can modify command functions, loot tables, world structures, advancements, and recipes.

Donts in creating data packs
Before creating data packs, there are a list of things that should not do. Here are the dont's list:
 * 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
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 we need to do is 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 lots of 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. This is okay!
 * 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! We won’t 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. Next, create a folder with your namespace. Most things in the game has a namespace, so that if we add something and a mod (or map, or whatever) adds something, they're both 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 default it to. This means that  and   are the same thing.

Please always use your own namespace for anything new that you add, and only use other namespaces if you're explicitly overriding something else. Try not to add new things in, basically. 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
Now we are ready to test 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 pack.mcmeta is correct. If it isn't, look for any missing curly braces { }, commas, colons :, quotation marks “”, or square brackets [ ]. Remember 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. 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 yor 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 can also change advancemants. Firstly, 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
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.