Views
Actions
Difference between revisions of "Datageneration/Recipes/1.18"
(Copy Datageneration/Recipes to MC1.18 archive) |
(No difference)
|
Latest revision as of 07:44, 10 June 2022
Recipes can be generated by creating an extension of Minecraft's RecipeProvider
class. From there, recipes can be registered by overriding RecipeProvider#buildCraftingRecipes
.
Info
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
#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
.