Difference between revisions of "Datageneration/Recipes"

From Forge Community Wiki
(changed the old block tag to colored box)
(Please brain, read words, update part 2)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Recipes can be generated by creating an extension of Minecraft's <code>RecipeProvider</code> class. From there, recipes can be registered by overriding <code>RecipeProvider#registerRecipes</code>.
+
Recipes can be generated by creating an extension of Minecraft's <code>RecipeProvider</code> class. From there, recipes can be registered by overriding <code>RecipeProvider#buildCraftingRecipes</code>.
  
 
{{Colored box|title=Info|content=Remove the <code>super</code> call within the method. Otherwise, you will generate all recipes from Minecraft as well.}}
 
{{Colored box|title=Info|content=Remove the <code>super</code> call within the method. Otherwise, you will generate all recipes from Minecraft as well.}}
Line 5: Line 5:
 
== Recipe Builders ==
 
== Recipe Builders ==
  
All recipes need to be formatted as an <code>IFinishedRecipe</code>. Each vanilla recipe has a static constructor builder that can be used to create a finished recipe. These can be built by passing the required parameters and then calling <code><nowiki>#build</nowiki></code>.
+
All recipes need to be formatted as an <code>FinishedRecipe</code>. Each vanilla recipe has a static constructor builder that can be used to create a finished recipe. These can be built by passing the required parameters and then calling <code><nowiki>#save</nowiki></code>.
  
{{Colored box|title=important|content=All recipes must have a different path. If two recipes have the same result, use <code><nowiki>#build(Consumer<IFinishedRecipe>, ResourceLocation)</nowiki></code> instead. This will allow you to specify a different name for the recipe such that it will not override the other.}}
+
{{Colored box|title=important|content=All recipes must have a different path. If two recipes have the same result, use <code><nowiki>#save(Consumer<FinishedRecipe>, ResourceLocation)</nowiki></code> instead. This will allow you to specify a different name for the recipe such that it will not override the other.}}
  
There are six vanilla recipe builders: <code>ShapedRecipeBuilder</code> for shaped recipes, <code>ShapelessRecipeBuilder</code> for shapeless recipes, <code>CookingRecipeBuilder</code> for furnace type recipes, <code>CustomRecipeBuilder</code> for nondeterministic logic, <code>SingleItemRecipeBuilder</code> for stonecutting recipes, and <code>SmithingRecipeBuilder</code> for smithing recipes.
+
There are six vanilla recipe builders: <code>ShapedRecipeBuilder</code> for shaped recipes, <code>ShapelessRecipeBuilder</code> for shapeless recipes, <code>SimpleCookingRecipeBuilder</code> for furnace type recipes, <code>SpecialRecipeBuilder</code> for nondeterministic logic, <code>SingleItemRecipeBuilder</code> for stonecutting recipes, and <code>UpgradeRecipeBuilder</code> for smithing recipes.
  
For any recipe to be valid, a criterion must be met to obtain the recipe within the recipe book. This can be attached via <code><nowiki>#addCriterion</nowiki></code>. The <code>RecipeProvider</code> class has some basic criteria creators to check whether a player's inventory has a certain item or whether a player has entered into a specific block.
+
For any recipe to be valid, a criterion must be met to obtain the recipe within the recipe book. This can be attached via <code><nowiki>#unlocks</nowiki></code>. The <code>RecipeProvider</code> class has some basic criteria creators to check whether a player's inventory has a certain item or whether a player has entered into a specific block.
  
 
== <code>ConditionalRecipe</code> ==
 
== <code>ConditionalRecipe</code> ==
  
 
To specify if a recipe should be loaded at runtime, a <code>ConditionalRecipe</code> can be used in conjunction with a recipe builder. Conditions must be added before the recipe via <code>ConditionalRecipe$Builder#addCondition</code>. Then, once a recipe is added, all previous conditions are cleared for the next to be added. There are a few helper methods for conditions that can be implemented via <code>IConditionBuilder</code>.
 
To specify if a recipe should be loaded at runtime, a <code>ConditionalRecipe</code> can be used in conjunction with a recipe builder. Conditions must be added before the recipe via <code>ConditionalRecipe$Builder#addCondition</code>. Then, once a recipe is added, all previous conditions are cleared for the next to be added. There are a few helper methods for conditions that can be implemented via <code>IConditionBuilder</code>.
 +
 +
 +
[[Category:Data Generation]]

Latest revision as of 23:01, 31 July 2021

Recipes can be generated by creating an extension of Minecraft's RecipeProvider class. From there, recipes can be registered by overriding RecipeProvider#buildCraftingRecipes.

Info

Remove the super call within the method. Otherwise, you will generate all recipes from Minecraft as well.

Recipe Builders

All recipes need to be formatted as an FinishedRecipe. Each vanilla recipe has a static constructor builder that can be used to create a finished recipe. These can be built by passing the required parameters and then calling #save.

important

All recipes must have a different path. If two recipes have the same result, use #save(Consumer<FinishedRecipe>, ResourceLocation) instead. This will allow you to specify a different name for the recipe such that it will not override the other.

There are six vanilla recipe builders: ShapedRecipeBuilder for shaped recipes, ShapelessRecipeBuilder for shapeless recipes, SimpleCookingRecipeBuilder for furnace type recipes, SpecialRecipeBuilder for nondeterministic logic, SingleItemRecipeBuilder for stonecutting recipes, and UpgradeRecipeBuilder for smithing recipes.

For any recipe to be valid, a criterion must be met to obtain the recipe within the recipe book. This can be attached via #unlocks. The RecipeProvider class has some basic criteria creators to check whether a player's inventory has a certain item or whether a player has entered into a specific block.

ConditionalRecipe

To specify if a recipe should be loaded at runtime, a ConditionalRecipe can be used in conjunction with a recipe builder. Conditions must be added before the recipe via ConditionalRecipe$Builder#addCondition. Then, once a recipe is added, all previous conditions are cleared for the next to be added. There are a few helper methods for conditions that can be implemented via IConditionBuilder.