How to write a custom datapack recipe
Minecraft datapacks offer a powerful way to customize your game experience, allowing you to add new content, modify existing features, and introduce unique mechanics. Among the most popular customizations is the creation of custom recipes. This guide will walk you through the process of writing a custom datapack recipe, ensuring you understand the underlying mechanics and can avoid common pitfalls.
![]()
Understanding Key Mechanics
At its core, a datapack is a ZIP archive or a folder placed within your Minecraft world’s save directory. These datapacks can profoundly customize various aspects of the game, including how items are crafted, smelted, or otherwise processed.
- Recipe Definition with JSON: All recipes within a datapack are defined using JSON (JavaScript Object Notation) files. JSON is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate.
- The
typeField: Every recipe file is fundamentally structured around atypefield. This crucial field specifies the category of the recipe, dictating how Minecraft will interpret and process it. Examples includeminecraft:crafting_shapedfor recipes that require a specific arrangement of items in a crafting grid, andminecraft:smeltingfor furnace-based recipes. - Shaped Crafting Recipes: For recipes where the arrangement of ingredients matters, such as crafting a pickaxe, shaped crafting recipes utilize a
pattern. This pattern visually represents the item arrangement within the crafting grid. Alongside the pattern, akeyis used to map specific characters (e.g., ‘X’, ‘I’, ‘#’) in the pattern to actual ingredients. These ingredients can be individual items (likeminecraft:cobblestone) or item tags (like#minecraft:planks, which allows any type of plank). - Shapeless Crafting Recipes: In contrast to shaped recipes, shapeless crafting recipes do not care about the arrangement of ingredients. Instead, they use an
ingredientslist to define all the required items. As long as all items in the list are present in the crafting grid, the recipe will yield its result, regardless of their position. - Recipe Result: Regardless of the recipe type, all recipes must specify a
result. This result defines the item that is produced by the recipe. It requires anid, which is the Minecraft identifier for the item (e.g.,minecraft:diamond_sword), and acount, indicating how many of that item are produced (e.g.,1). - The
pack.mcmetaFile: Essential for any datapack, thepack.mcmetafile resides at the root of your datapack folder. It’s a JSON file that defines the datapack’s fundamental properties: itspack_format, which indicates compatibility with specific Minecraft versions (e.g., 71 for 1.21.5), and adescription, which is a short text displayed in the game’s datapack menu. - Overriding Vanilla Recipes: Datapacks offer the capability to modify or replace existing vanilla recipes. This is achieved by creating a recipe file within your datapack that has the exact same name and folder structure as the vanilla recipe you intend to override. Minecraft will prioritize your datapack’s version.
Step-by-Step Process for Creating a Custom Recipe
Creating a custom recipe involves a series of structured steps, from locating the correct folders to writing the JSON and testing it in-game.
- Locate the
datapacksfolder: Your journey begins by navigating to your Minecraft world’s save folder. This is typically found at.minecraft/saves/YOUR_WORLD_NAME/datapacks/. The.minecraftfolder is usually in your user’s application data directory. - Create your datapack folder: Inside the
datapacksfolder, create a new folder that will house all the content for your custom datapack. It’s crucial to use lowercase letters and underscores for the folder name (e.g.,my_custom_pack) to ensure compatibility and avoid potential issues. - Create
pack.mcmeta: Within the datapack folder you just created, you must place a file namedpack.mcmeta. This file is written in JSON format and contains vital information for Minecraft to recognize and load your datapack. It requires apack_formatvalue, which corresponds to the Minecraft version your datapack is designed for (e.g.,71for Minecraft 1.21.5), and adescription, which is a text string that will be displayed in the game’s datapack selection screen. For example:{ "pack": { "pack_format": 71, "description": "My Awesome Custom Recipes" } } - Create folder structure: Inside your datapack folder, you need to establish a specific hierarchy to store your recipe files. First, create a folder named
data. Inside thedatafolder, create another folder named after your chosen namespace (e.g.,my_namespace). This namespace helps prevent conflicts with other datapacks or vanilla content. Finally, inside your namespace folder, create a folder namedrecipe. Note that for newer versions of Minecraft, the folder name for recipes is singular. So, the full path will look something likemy_custom_pack/data/my_namespace/recipe/. - Write the recipe JSON: Now, inside the
recipefolder, create a new JSON file for your specific recipe (e.g.,my_special_sword.json). This is where you define all the properties of your custom recipe. You will need to specify thetype(e.g.,minecraft:crafting_shaped), thepatternandkeyfor shaped recipes, or theingredientslist for shapeless recipes, and finally, theresultitem with itsidandcount. - Save the file: After meticulously defining your recipe in JSON, save the file. It is paramount to ensure that the JSON is correctly formatted. Even a single missing comma or bracket can prevent the recipe from loading.
- Reload in Minecraft: Once your datapack files are saved, you need to tell Minecraft to load them. Open your Minecraft world, and in the chat, type the command
/reload. This command will refresh all loaded datapacks, including your newly added or modified one. - Verify: To confirm that your datapack has loaded successfully, you can use the command
/datapack listin the chat. This will display a list of all active datapacks. After confirming it’s active, test your recipe in-game by trying to craft the item you defined.
Important Tips for Recipe Creation
To streamline your recipe creation process and minimize errors, consider these helpful tips:
- Use online generators: For beginners and experienced creators alike, websites such as misode.github.io/recipe/ are invaluable tools. They provide an intuitive interface for building recipe JSONs, often including visual previews of crafting patterns, which significantly reduces the chance of syntax errors and speeds up development.
- Text editor: While basic text editors can work, using a dedicated code editor like Visual Studio Code is highly recommended. These editors offer features such as JSON syntax highlighting, auto-completion, and validation, making it much easier to spot and fix errors in your recipe files.
- Item tags: To make your recipes more flexible, utilize item tags in the
keysection of shaped recipes or within theingredientslist. For example, instead of specifyingminecraft:oak_planks, you can use#minecraft:planks. This allows players to use any type of wood plank (oak, spruce, birch, etc.) to craft your item, making the recipe more user-friendly. - Override existing recipes: If your goal is to change a vanilla recipe, ensure that your custom recipe file has the exact same name and path as the original vanilla recipe. This tells Minecraft to use your version instead of the default one.
- Disable recipes: To effectively remove or disable a recipe, you can override it with a specific JSON structure. Set the
resultitem’sidtominecraft:airand itscountto0or1. This essentially makes the recipe yield nothing, thus disabling it from the game. - Frequent testing: Develop a habit of frequently reloading your datapack using
/reloadand testing your recipes in-game. This iterative approach allows you to quickly identify and troubleshoot any issues, saving you time and frustration in the long run.
Common Mistakes to Avoid
Even with careful planning, certain common errors can arise when creating datapack recipes. Being aware of these can help you prevent them:
- JSON syntax errors: The most frequent culprit for recipe failures is incorrect JSON syntax. Missing commas between fields, unclosed brackets
[]or curly braces{}, or incorrect quotation marks for string values will prevent your recipe from loading. Always double-check your JSON structure. - Incorrect folder hierarchy or naming: Datapacks are very particular about their internal structure. An incorrect folder name (e.g.,
recipesinstead ofrecipe, especially for newer versions), or placing files in the wrong subfolder (e.g., not underdata/YOUR_NAMESPACE/recipe/), will cause your datapack to be ignored or fail to load the recipes. - Wrong
pack_format: Thepack_formatvalue in yourpack.mcmetafile must precisely match the Minecraft version you are playing on. Using an outdated or future format will lead to your datapack not being recognized or loaded correctly. - Not using
/reload: After making any changes to your datapack files, Minecraft will not automatically detect them. For your changes to take effect, you must manually execute the/reloadcommand in the game chat. Forgetting this step is a common source of confusion when changes don’t appear. - Attempting to put multiple items in one slot: In both shaped and shapeless crafting recipes, each slot in the crafting grid (or each entry in the
ingredientslist for shapeless recipes) is designed to accept only one type of item, not multiple stacks or different item types simultaneously within that single definition. - Incorrect recipe ID for overrides: When attempting to override a vanilla recipe, the JSON filename you create for your custom recipe must precisely match the internal ID of the vanilla recipe you wish to replace. Any discrepancy will result in your recipe being treated as a new, separate recipe rather than an override.