Crafting Recipes
Create custom crafting recipes with ease
Overview
The Crafting
class provides a utility for creating custom crafting recipes in Bukkit.
Constructors
Crafting(JavaPlugin plugin, ItemStack result, String key)
Crafting(JavaPlugin plugin, ItemStack result, String key)
Creates a new instance of the Crafting
class with the specified result item and recipe key.
Parameters
plugin
: The JavaPlugin instance representing the plugin that owns this recipe.result
: The ItemStack representing the result of the crafting recipe.key
: The key used to identify this recipe.
Methods
setShape
setShape
Sets the shape of the crafting recipe.
Parameters
shape
: An array of strings representing the crafting grid.
setIngredient
setIngredient
Sets an ingredient for the crafting recipe using a Material.
Parameters
key
: The character representing the ingredient's position in the crafting grid.material
: The Material of the ingredient.amount
: The amount of the ingredient required.
Sets an ingredient for the crafting recipe using an ItemStack.
Parameters
key
: The character representing the ingredient's position in the crafting grid.itemStack
: The ItemStack representing the ingredient.amount
: The amount of the ingredient required.
build
build
Builds and returns the ShapedRecipe instance representing the crafting recipe.
Usage
Create a new instance of the
Crafting
class with the desired result item and recipe key.Set the shape of the crafting recipe using the
setShape
method.Add ingredients to the recipe using the
setIngredient
method.Build the recipe using the
build
method.Register the recipe with Bukkit using
Bukkit.addRecipe
.
Example
In this example, we create a custom crafting recipe for a diamond sword (result
) using various materials and items.
Last updated