In this tutorial you will learn how to add a recipe to the game, you can do that in two ways, either the Data Driven way where you add them using a json file or the Code Driven way where you define them programmaticaly. I personally recommend using the data driven approach when possible and only using the code driven way when required.
You can learn more about both ways on their respective pages:
Data Driven Recipes
Code Driven Recipes
Adding Data Driven Recipes
Data Driven recipes are defined in the JSON format and need to be put under the src/main/resources/data/<modid>/stationapi/recipes/
folder.
Shapeless Recipe
Shapeless Recipe doesn’t care about the order of the items put into the crafting table, it only cares that the correct ingredients are supplied.
To create a shapeless crafting recipe you need to make a new recipe of the minecraft:crafting_shapeless
type, you can read more about this here.
And here is the result:
Shaped Recipe
Shaped Recipe does care about the order of the ingredients in the crafting grid.
To create a shaped crafting recipe you need to make a new recipe of the minecraft:crafting_shaped
type, you can read more about this here.
And here is the result:
Smelting Recipe
Smelting Recipe only has a single input and output.
To create a smelting recipe you need to make a new recipe of the minecraft:smelting
type, you can read more about this here.
And here is the result:
Adding Code Driven Recipes
Code driven recipes are defined programmatically and need to be registered using the RecipeRegisterEvent
Shapeless Recipe
Shapeless Recipe doesn’t care about the order of the items put into the crafting table, it only cares that the correct ingredients are supplied.
To create a shapeless crafting recipe you need to use the CraftingRegistry.addShapelessRecipe
method during the RecipeRegisterEvent.Vanilla.CRAFTING_SHAPELESS
event. You can read more about this here
And here is the result:
Shaped Recipe
Shaped Recipe does care about the order of the ingredients in the crafting grid.
To create a shapeless crafting recipe you need to use the CraftingRegistry.addShapedRecipe
method during the RecipeRegisterEvent.Vanilla.CRAFTING_SHAPED
event. You can read more about this here
And here is the result:
Smelting Recipe
Smelting Recipe only has a single input and output.
To create a smelting recipe you need to use the SmeltingRegistry.addSmeltingRecipe
method during the RecipeRegisterEvent.Vanilla.SMELTING
event. You can read more about this here
And here is the result:
External Resources:
Data Driven Recipes:
Minecraft Wiki/Recipe - Since StationAPI uses the modern data driven recipes, the basics of this are applicable, altho many of the things are straight up non-existent in Beta
Fabric Wiki/Crafting Recipes - This is also somewhat applicable, altho not really comprehensive
Examples:
Tropicraft Recipes
StationAPI Test Mod Recipes
NyaWiki Example Mod Recipes
Better Nether Beta Recipes
Code Driven Recipes:
Examples:
NyaWiki Example Mod
StationAPI Test Mod