craftingrecipes v2.0.0
craftingrecipes
Recipes for crafting items with inventory and itempile.
Used by:
Recipe Classes
All recipe classes implement:
computeOutput(inventory)
: returns an ItemPile for the crafting result of the given inventory input ingredients, or undefinedmatches(inventory)
: returns true if this recipe matches the given ingredientscraft(inventory)
: consumes input ingredients from inventory and returns ItemPile result, or undefined if doesn't match
The following recipe classes are implemented in this module:
AmorphousRecipe
: ingredients are accepted in any orderPositionalRecipe
: ingredients must match at certain positions
You can define your own recipe classes as long as they extend Recipe
(see
voxel-pickaxe's repair recipe for an example).
Recipe Lists
RecipeList
manages a list of recipes and can search an inventory against each of them.
This is the ordinary use case of this module. Register your recipes in RecipeList
then
result = craft(inventory)
to search and craft.
craftingrecipes can be loaded through voxel-plugins for a centralized recipe list shared amongst multiple plugins.
Crafting Thesaurus
CraftingThesaurus
provides a mapping from a convenient general name to a specific
item name of that category. This is used to allow different items, all of the same
general "type", to be used as crafting inputs. Amorphous and positional recipes automatically
support the thesaurus.
The thesaurus is useful when you have interchangeable items, for example, different species of wood, all usable in the same recipes (or different kinds of dyes, also intended to be interchangeable, etc.). The general name "wood.log" can be registered for "logOak", "logBirch", and future potential items, then wood.log can be specified in a recipe definition as ingredients, and when matching the recipe against this ingredient, any of the listed items can be used.
For known registered names used by other plugins, see the wiki.
Examples
See unit tests
License
MIT