With models and loot tables generating automatically, the next step is crafting recipes. NeoForge's datagen system handles these through a RecipeProvider, which lets you define shaped, shapeless, smelting and blasting recipes entirely in Java and outputs the corresponding JSON files into the common project alongside everything else.
gatherData method.Recipe Provider
In your NeoForge data package, create a class called ExampleRecipeProvider extending RecipeProvider. Unlike the loot and model providers, RecipeProvider receives the lookup registries as a CompletableFuture rather than a resolved instance:
All recipe definitions go inside buildRecipes. The RecipeOutput parameter collects each recipe and its associated advancement unlock condition and writes both to JSON during datagen.
Shaped Recipes
A shaped recipe requires ingredients to be placed in a specific pattern in the crafting grid. Use ShapedRecipeBuilder to define the pattern, map each character to an ingredient, then provide an advancement criterion that unlocks the recipe in the recipe book. Here we craft four Iron Sticks from two iron ingots placed vertically:
Each row of pattern corresponds to one row in the crafting grid. Characters can be anything except a space, which always means an empty slot. The define call maps the character to an ingredient, which can be a single item, a tag, or a compound ingredient.
The file generated for the above recipe will be saved at data/examplemod/recipe/iron_stick.json:
TagKey<Item> to define instead of an ItemLike. This lets players substitute any item in the tag, for example using any plank variant where a specific plank would otherwise be required.Shapeless Recipes
A shapeless recipe accepts its ingredients in any arrangement. Use ShapelessRecipeBuilder and call requires once per ingredient slot. Here we convert dirt and an Iron Stick into a New Dirt block as a simple demonstration:
When the output item already has a shaped recipe saved under its registry name, pass an explicit ResourceLocation as the second argument to save to give this recipe a unique file name and avoid a clash.
Smelting and Blasting
Furnace recipes use SimpleCookingRecipeBuilder. The static factory methods smelting and blasting select the recipe type automatically. Here we smelt New Dirt into Coarse Dirt at 0.1 experience per operation:
The four arguments after the ingredient are: the output item, XP reward, and cooking time in ticks (20 ticks per second). Blasting recipes conventionally use half the cook time of the equivalent smelting recipe.
SimpleCookingRecipeBuilder.smoking for smoker recipes and SimpleCookingRecipeBuilder.campfireCooking for campfire recipes.Registering the Provider
Open the gatherData method in your NeoForge mod class and register the recipe provider alongside the existing ones. The lookup provider is passed as a CompletableFuture from the event:
Running Datagen
Run the NeoForge Data configuration. After it completes, check common/src/generated/resources/data/examplemod/recipe/. You should see one file per recipe you registered. Launch the client and confirm:
- The shaped recipe for Iron Stick appears in the crafting table recipe book once you pick up an iron ingot.
- The shapeless New Dirt recipe works with the ingredients in any slot arrangement.
- New Dirt can be smelted in a furnace and blasted in a blast furnace, yielding Coarse Dirt.
unlockedBy criterion. In creative mode all recipes are visible regardless, so switch to survival or use /recipe give @s * when testing unlock behaviour.You can find the source for this tutorial here:
View Source on GitHubData Generation: Block & Item Tags (MultiLoader 1.21+)
Generate block and item tag files with BlockTagsProvider and ItemTagsProvider, add your custom block to vanilla tool-requirement tags, and create a mod-scoped item tag for use as a recipe ingredient.
Continue →