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 26.1, RecipeProvider uses a two-class pattern. The provider itself receives the fully resolved HolderLookup.Provider and a RecipeOutput through its constructor. A static inner Runner class handles the asynchronous lookup resolution and is what you register with the data generator.
In your NeoForge data package, create ExampleRecipeProvider:
All recipe definitions go inside buildRecipes(). Unlike earlier NeoForge versions, this method takes no parameters: the RecipeOutput is stored as a protected field (output) by the parent constructor, so you reference it directly when calling save on each builder. The Runner is what you register with the generator; it resolves the async lookup and then delegates to createRecipeProvider to construct the actual provider instance.
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 Identifier 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 Runner alongside the existing loot provider:
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 26.1+)
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 →