Package org.bukkit.inventory
Class ShapedRecipe
java.lang.Object
org.bukkit.inventory.ShapedRecipe
Represents a shaped (ie normal) crafting recipe.
-
Constructor Summary
ConstructorDescriptionShapedRecipe
(ItemStack result) Deprecated.Recipes must have keys.ShapedRecipe
(NamespacedKey key, ItemStack result) Create a shaped recipe to craft the specified ItemStack. -
Method Summary
Modifier and TypeMethodDescriptionGets the category which this recipe will appear in the recipe book under.Get a copy of the choice map.getGroup()
Get the group of this recipe.Get a copy of the ingredients map.getKey()
Return the namespaced identifier for this object.Get the result.String[]
getShape()
Get the shape.void
setCategory
(CraftingBookCategory category) Sets the category which this recipe will appear in the recipe book under.void
Set the group of this recipe.setIngredient
(char key, RecipeChoice ingredient) Sets theRecipeChoice
that a character in the recipe shape refers to.setIngredient
(char key, Material ingredient) Sets the material that a character in the recipe shape refers to.setIngredient
(char key, MaterialData ingredient) Sets the material that a character in the recipe shape refers to.setIngredient
(char key, Material ingredient, int raw) Deprecated.Magic valueSet the shape of this recipe to the specified rows.
-
Constructor Details
-
ShapedRecipe
Deprecated.Recipes must have keys. UseShapedRecipe(NamespacedKey, ItemStack)
instead.Create a shaped recipe to craft the specified ItemStack. The constructor merely determines the result and type; to set the actual recipe, you'll need to call the appropriate methods.- Parameters:
result
- The item you want the recipe to create.- See Also:
-
ShapedRecipe
Create a shaped recipe to craft the specified ItemStack. The constructor merely determines the result and type; to set the actual recipe, you'll need to call the appropriate methods.- Parameters:
key
- the unique recipe keyresult
- The item you want the recipe to create.- See Also:
-
-
Method Details
-
shape
Set the shape of this recipe to the specified rows. Each character represents a different ingredient; exactly what each character represents is set separately. The first row supplied corresponds with the upper most part of the recipe on the workbench e.g. if all three rows are supplies the first string represents the top row on the workbench.- Parameters:
shape
- The rows of the recipe (up to 3 rows).- Returns:
- The changed recipe, so you can chain calls.
-
setIngredient
Sets the material that a character in the recipe shape refers to.Note that before an ingredient can be set, the recipe's shape must be defined with
shape(String...)
.- Parameters:
key
- The character that represents the ingredient in the shape.ingredient
- The ingredient.- Returns:
- The changed recipe, so you can chain calls.
- Throws:
IllegalArgumentException
- if thekey
does not appear in the shape.
-
setIngredient
Sets the material that a character in the recipe shape refers to.Note that before an ingredient can be set, the recipe's shape must be defined with
shape(String...)
.- Parameters:
key
- The character that represents the ingredient in the shape.ingredient
- The ingredient.- Returns:
- The changed recipe, so you can chain calls.
- Throws:
IllegalArgumentException
- if thekey
does not appear in the shape.
-
setIngredient
@Deprecated @NotNull public ShapedRecipe setIngredient(char key, @NotNull Material ingredient, int raw) Deprecated.Magic valueSets the material that a character in the recipe shape refers to.Note that before an ingredient can be set, the recipe's shape must be defined with
shape(String...)
.- Parameters:
key
- The character that represents the ingredient in the shape.ingredient
- The ingredient.raw
- The raw material data as an integer.- Returns:
- The changed recipe, so you can chain calls.
- Throws:
IllegalArgumentException
- if thekey
does not appear in the shape.
-
setIngredient
Sets theRecipeChoice
that a character in the recipe shape refers to.Note that before an ingredient can be set, the recipe's shape must be defined with
shape(String...)
.- Parameters:
key
- The character that represents the ingredient in the shape.ingredient
- The ingredient.- Returns:
- The changed recipe, so you can chain calls.
- Throws:
IllegalArgumentException
- if thekey
does not appear in the shape.
-
getIngredientMap
Get a copy of the ingredients map.- Returns:
- The mapping of character to ingredients.
-
getChoiceMap
Get a copy of the choice map.- Returns:
- The mapping of character to ingredients.
-
getShape
Get the shape.- Returns:
- The recipe's shape.
- Throws:
NullPointerException
- when not set yet
-
getResult
Get the result. -
getKey
Description copied from interface:Keyed
Return the namespaced identifier for this object. -
getGroup
Get the group of this recipe. Recipes with the same group may be grouped together when displayed in the client.- Returns:
- recipe group. An empty string denotes no group. May not be null.
-
setGroup
Set the group of this recipe. Recipes with the same group may be grouped together when displayed in the client.- Parameters:
group
- recipe group. An empty string denotes no group. May not be null.
-
getCategory
Gets the category which this recipe will appear in the recipe book under. Defaults toCraftingBookCategory.MISC
if not set.- Returns:
- recipe book category
-
setCategory
Sets the category which this recipe will appear in the recipe book under. Defaults toCraftingBookCategory.MISC
if not set.- Parameters:
category
- recipe book category
-