@CatalogedBy(value=CraftingRecipes.class) public interface CraftingRecipe extends Recipe, CatalogType
It is essentially a Predicate that checks for if a recipe is valid as well
as a function from a crafting matrix to a list of ItemStack (the
crafting result), therefore making it an immutable interface.
The passed in CraftingGridInventory is usually a crafting
inventory, e.g. a 2x2 or 3x3 crafting matrix.
The requirements of a CraftingRecipe can be general, they just have to eventually return a boolean given an crafting grid.
getExemplaryResultgetId, getNameboolean isValid(CraftingGridInventory grid, World world)
CraftingGridInventory fits the required
constraints to craft this CraftingGridInventory.grid - The CraftingGridInventory to check for validityworld - The world this recipe would be used inItemStackSnapshot getResult(CraftingGridInventory grid)
isValid(CraftingGridInventory, World) returns true.
This method is preferred over the
Recipe.getExemplaryResult() method, as it customizes
the result further depending on the context.
Implementing classes are advised to use the output of
Recipe.getExemplaryResult(), modify it accordingly,
and return it.
grid - The crafting input, typically 3x3 or 2x2ItemStackSnapshotdefault Optional<CraftingResult> getResult(CraftingGridInventory grid, World world)
CraftingResult for the current crafting grid
configuration and the World the player is in.
Returns
Optional.empty() if the arguments do not satisfy
isValid(CraftingGridInventory, World).
grid - The crafting input, typically 3x3 or 2x2world - The world this recipe would be used inCraftingResult if the arguments satisfy
isValid(CraftingGridInventory, World), or
Optional.empty() if notList<ItemStackSnapshot> getRemainingItems(CraftingGridInventory grid)
isValid(CraftingGridInventory, World) returns true.
A list of items to be added to the inventory of the player when they
craft the result. For example, if a player crafts a
ItemTypes.CAKE, the empty buckets are returned to their
inventory.
grid - The crafting input, typically 3x3 or 2x2Optional<String> getGroup()
Optional.empty()
if not defined.static ShapedCraftingRecipe.Builder shapedBuilder()
ShapedCraftingRecipe.static ShapelessCraftingRecipe.Builder shapelessBuilder()
ShapelessCraftingRecipe.