public class ShapedCraftingRecipe extends java.lang.Object implements CraftingRecipe
Crafting recipes can be specified as a 2-dimensional array of ingredients (with Optional.empty() being used for empty spots) or as a 1-dimensional array of ingredients and a pattern string (lines are separated by -, spaces for empty spots, A-Z for ingredients.
For instance, to define a stick recipe with a pattern string:
new ShapedCraftingRecipe("A - A", ItemIngredient.forDictionary("plankWood"));
Two kinds of recipes can be defined: basic or advanced. Basic recipes always return the same item, while advanced recipes have their output defined by a lambda expression. RecipeFunctions will receive information about the
| Constructor and Description |
|---|
ShapedCraftingRecipe(ItemFactory output,
java.util.Optional<ItemIngredient>[][] ingredients)
Defines a basic crafting recipe, using a 2D ingredients array.
|
ShapedCraftingRecipe(ItemFactory output,
java.util.Optional<ItemIngredient>[][] ingredients,
boolean mirrored)
Defines a basic crafting recipe, using a 2D ingredients array.
|
ShapedCraftingRecipe(ItemFactory output,
RecipeFunction recipeFunction,
java.util.Optional<ItemIngredient>[][] ingredients)
Defines a basic crafting recipe, using a 2D ingredients array.
|
ShapedCraftingRecipe(ItemFactory output,
RecipeFunction recipeFunction,
java.util.Optional<ItemIngredient>[][] ingredients,
boolean mirrored)
Defines an advanced crafting recipe, using a 2D ingredients array.
|
ShapedCraftingRecipe(ItemFactory output,
RecipeFunction recipeFunction,
java.lang.String format,
boolean mirrored,
ItemIngredient... ingredients)
Defines an advanced crafting recipe, using a format string.
|
ShapedCraftingRecipe(ItemFactory output,
RecipeFunction recipeFunction,
java.lang.String format,
ItemIngredient... ingredients)
Defines an advanced crafting recipe, using a format string.
|
ShapedCraftingRecipe(ItemFactory output,
java.lang.String format,
boolean mirrored,
ItemIngredient... ingredients)
Defines a basic structured crafting recipe, possibly mirrored, using a format string.
|
ShapedCraftingRecipe(ItemFactory output,
java.lang.String format,
ItemIngredient... ingredients)
Defines a basic structured crafting recipe, using a format string.
|
| Modifier and Type | Method and Description |
|---|---|
void |
consumeItems(CraftingGrid craftingGrid)
Consumes items for the crafting of a single item.
|
java.util.Optional<Item> |
getCraftingResult(CraftingGrid craftingGrid)
Calculates the crafting result for the given crafting grid.
|
java.util.Optional<Item> |
getExampleOutput()
Gets a nominal (example) output for this recipe.
|
int |
getHeight() |
ItemIngredient[] |
getIngredients() |
int[] |
getIngredientsX() |
int[] |
getIngredientsY() |
java.util.Collection<java.lang.String> |
getPossibleItemsInFirstSlot()
Gets the possible items for this recipe in the first non-empty recipe
slot.
|
int |
getWidth() |
boolean |
isMirrored() |
boolean |
matches(CraftingGrid inventory)
Checks if this crafting recipe matches the content of the given crafting
grid.
|
public ShapedCraftingRecipe(ItemFactory output, java.lang.String format, ItemIngredient... ingredients)
output - Output Item of the recipeformat - Formatingredients - ItemIngredientspublic ShapedCraftingRecipe(ItemFactory output, java.lang.String format, boolean mirrored, ItemIngredient... ingredients)
output - Output Item of the recipeformat - Formatmirrored - Whether this recipe is mirroredingredients - ItemIngredientspublic ShapedCraftingRecipe(ItemFactory output, RecipeFunction recipeFunction, java.lang.String format, ItemIngredient... ingredients)
output - Nominal output of the reciperecipeFunction - RecipeFunctionformat - Formatingredients - ItemIngredientspublic ShapedCraftingRecipe(ItemFactory output, RecipeFunction recipeFunction, java.lang.String format, boolean mirrored, ItemIngredient... ingredients)
output - Nominal output of the reciperecipeFunction - RecipeFunctionformat - Formatmirrored - Whether this recipe is mirroredingredients - ItemIngredientspublic ShapedCraftingRecipe(ItemFactory output, java.util.Optional<ItemIngredient>[][] ingredients)
output - Output Item of the recipeingredients - ItemIngredientspublic ShapedCraftingRecipe(ItemFactory output, java.util.Optional<ItemIngredient>[][] ingredients, boolean mirrored)
output - Output Item of the recipeingredients - ItemIngredientsmirrored - Whether this recipe is mirroredpublic ShapedCraftingRecipe(ItemFactory output, RecipeFunction recipeFunction, java.util.Optional<ItemIngredient>[][] ingredients)
output - Output Item of the reciperecipeFunction - RecipeFunctioningredients - ItemIngredientspublic ShapedCraftingRecipe(ItemFactory output, RecipeFunction recipeFunction, java.util.Optional<ItemIngredient>[][] ingredients, boolean mirrored)
output - Nominal output of the reciperecipeFunction - RecipeFunctioningredients - ItemIngredientsmirrored - Whether this recipe is mirroredpublic int getWidth()
public int getHeight()
public boolean isMirrored()
public ItemIngredient[] getIngredients()
public int[] getIngredientsX()
public int[] getIngredientsY()
public boolean matches(CraftingGrid inventory)
CraftingRecipematches in interface CraftingRecipeinventory - crafting grid to read frompublic java.util.Optional<Item> getCraftingResult(CraftingGrid craftingGrid)
CraftingRecipegetCraftingResult in interface CraftingRecipecraftingGrid - crafting gridpublic void consumeItems(CraftingGrid craftingGrid)
CraftingRecipeconsumeItems in interface CraftingRecipecraftingGrid - crafting grid to modifypublic java.util.Collection<java.lang.String> getPossibleItemsInFirstSlot()
CraftingRecipegetPossibleItemsInFirstSlot in interface CraftingRecipepublic java.util.Optional<Item> getExampleOutput()
CraftingRecipegetExampleOutput in interface CraftingRecipe