Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.inventory.ShapelessRecipe Class Reference
Inheritance diagram for org.bukkit.inventory.ShapelessRecipe:
org.bukkit.inventory.Recipe

Public Member Functions

 ShapelessRecipe (ItemStack result)
 
ShapelessRecipe addIngredient (MaterialData ingredient)
 
ShapelessRecipe addIngredient (Material ingredient)
 
ShapelessRecipe addIngredient (Material ingredient, int rawdata)
 
ShapelessRecipe addIngredient (int count, MaterialData ingredient)
 
ShapelessRecipe addIngredient (int count, Material ingredient)
 
ShapelessRecipe addIngredient (int count, Material ingredient, int rawdata)
 
ShapelessRecipe removeIngredient (Material ingredient)
 
ShapelessRecipe removeIngredient (MaterialData ingredient)
 
ShapelessRecipe removeIngredient (int count, Material ingredient)
 
ShapelessRecipe removeIngredient (int count, MaterialData ingredient)
 
ShapelessRecipe removeIngredient (Material ingredient, int rawdata)
 
ShapelessRecipe removeIngredient (int count, Material ingredient, int rawdata)
 
ItemStack getResult ()
 
List< ItemStackgetIngredientList ()
 

Detailed Description

Represents a shapeless recipe, where the arrangement of the ingredients on the crafting grid does not matter.

Definition at line 16 of file ShapelessRecipe.java.

Constructor & Destructor Documentation

org.bukkit.inventory.ShapelessRecipe.ShapelessRecipe ( ItemStack  result)

Create a shapeless 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
resultThe item you want the recipe to create.
See also
ShapelessRecipe::addIngredient(Material)
ShapelessRecipe::addIngredient(MaterialData)
ShapelessRecipe::addIngredient(Material,int)
ShapelessRecipe::addIngredient(int,Material)
ShapelessRecipe::addIngredient(int,MaterialData)
ShapelessRecipe::addIngredient(int,Material,int)

Definition at line 33 of file ShapelessRecipe.java.

33  {
34  this.output = new ItemStack(result);
35  }

Member Function Documentation

ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.addIngredient ( MaterialData  ingredient)

Adds the specified ingredient.

Parameters
ingredientThe ingredient to add.
Returns
The changed recipe, so you can chain calls.

Definition at line 43 of file ShapelessRecipe.java.

Referenced by org.bukkit.inventory.ShapelessRecipe.addIngredient().

43  {
44  return addIngredient(1, ingredient);
45  }
ShapelessRecipe addIngredient(MaterialData ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.addIngredient ( Material  ingredient)

Adds the specified ingredient.

Parameters
ingredientThe ingredient to add.
Returns
The changed recipe, so you can chain calls.

Definition at line 53 of file ShapelessRecipe.java.

References org.bukkit.inventory.ShapelessRecipe.addIngredient().

53  {
54  return addIngredient(1, ingredient, 0);
55  }
ShapelessRecipe addIngredient(MaterialData ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.addIngredient ( Material  ingredient,
int  rawdata 
)

Adds the specified ingredient.

Parameters
ingredientThe ingredient to add.
rawdataThe data value, or -1 to allow any data value.
Returns
The changed recipe, so you can chain calls.
Deprecated:
Magic value

Definition at line 66 of file ShapelessRecipe.java.

References org.bukkit.inventory.ShapelessRecipe.addIngredient().

66  {
67  return addIngredient(1, ingredient, rawdata);
68  }
ShapelessRecipe addIngredient(MaterialData ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.addIngredient ( int  count,
MaterialData  ingredient 
)

Adds multiples of the specified ingredient.

Parameters
countHow many to add (can't be more than 9!)
ingredientThe ingredient to add.
Returns
The changed recipe, so you can chain calls.

Definition at line 77 of file ShapelessRecipe.java.

References org.bukkit.inventory.ShapelessRecipe.addIngredient(), org.bukkit.material.MaterialData.getData(), and org.bukkit.material.MaterialData.getItemType().

77  {
78  return addIngredient(count, ingredient.getItemType(), ingredient.getData());
79  }
ShapelessRecipe addIngredient(MaterialData ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.addIngredient ( int  count,
Material  ingredient 
)

Adds multiples of the specified ingredient.

Parameters
countHow many to add (can't be more than 9!)
ingredientThe ingredient to add.
Returns
The changed recipe, so you can chain calls.

Definition at line 88 of file ShapelessRecipe.java.

References org.bukkit.inventory.ShapelessRecipe.addIngredient().

88  {
89  return addIngredient(count, ingredient, 0);
90  }
ShapelessRecipe addIngredient(MaterialData ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.addIngredient ( int  count,
Material  ingredient,
int  rawdata 
)

Adds multiples of the specified ingredient.

Parameters
countHow many to add (can't be more than 9!)
ingredientThe ingredient to add.
rawdataThe data value, or -1 to allow any data value.
Returns
The changed recipe, so you can chain calls.
Deprecated:
Magic value

Definition at line 102 of file ShapelessRecipe.java.

102  {
103  Validate.isTrue(ingredients.size() + count <= 9, "Shapeless recipes cannot have more than 9 ingredients");
104 
105  // -1 is the old wildcard, map to Short.MAX_VALUE as the new one
106  if (rawdata == -1) {
107  rawdata = Short.MAX_VALUE;
108  }
109 
110  while (count-- > 0) {
111  ingredients.add(new ItemStack(ingredient, 1, (short) rawdata));
112  }
113  return this;
114  }
List<ItemStack> org.bukkit.inventory.ShapelessRecipe.getIngredientList ( )

Get the list of ingredients used for this recipe.

Returns
The input list

Definition at line 219 of file ShapelessRecipe.java.

219  {
220  ArrayList<ItemStack> result = new ArrayList<ItemStack>(ingredients.size());
221  for (ItemStack ingredient : ingredients) {
222  result.add(ingredient.clone());
223  }
224  return result;
225  }
ItemStack org.bukkit.inventory.ShapelessRecipe.getResult ( )

Get the result of this recipe.

Returns
The result stack.

Implements org.bukkit.inventory.Recipe.

Definition at line 210 of file ShapelessRecipe.java.

210  {
211  return output.clone();
212  }
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.removeIngredient ( Material  ingredient)

Removes an ingredient from the list. If the ingredient occurs multiple times, only one instance of it is removed. Only removes exact matches, with a data value of 0.

Parameters
ingredientThe ingredient to remove
Returns
The changed recipe.

Definition at line 124 of file ShapelessRecipe.java.

Referenced by org.bukkit.inventory.ShapelessRecipe.removeIngredient().

124  {
125  return removeIngredient(ingredient, 0);
126  }
ShapelessRecipe removeIngredient(Material ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.removeIngredient ( MaterialData  ingredient)

Removes an ingredient from the list. If the ingredient occurs multiple times, only one instance of it is removed. If the data value is -1, only ingredients with a -1 data value will be removed.

Parameters
ingredientThe ingredient to remove
Returns
The changed recipe.

Definition at line 136 of file ShapelessRecipe.java.

References org.bukkit.material.MaterialData.getData(), org.bukkit.material.MaterialData.getItemType(), and org.bukkit.inventory.ShapelessRecipe.removeIngredient().

136  {
137  return removeIngredient(ingredient.getItemType(), ingredient.getData());
138  }
ShapelessRecipe removeIngredient(Material ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.removeIngredient ( int  count,
Material  ingredient 
)

Removes multiple instances of an ingredient from the list. If there are less instances then specified, all will be removed. Only removes exact matches, with a data value of 0.

Parameters
countThe number of copies to remove.
ingredientThe ingredient to remove
Returns
The changed recipe.

Definition at line 149 of file ShapelessRecipe.java.

References org.bukkit.inventory.ShapelessRecipe.removeIngredient().

149  {
150  return removeIngredient(count, ingredient, 0);
151  }
ShapelessRecipe removeIngredient(Material ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.removeIngredient ( int  count,
MaterialData  ingredient 
)

Removes multiple instances of an ingredient from the list. If there are less instances then specified, all will be removed. If the data value is -1, only ingredients with a -1 data value will be removed.

Parameters
countThe number of copies to remove.
ingredientThe ingredient to remove.
Returns
The changed recipe.

Definition at line 162 of file ShapelessRecipe.java.

References org.bukkit.material.MaterialData.getData(), org.bukkit.material.MaterialData.getItemType(), and org.bukkit.inventory.ShapelessRecipe.removeIngredient().

162  {
163  return removeIngredient(count, ingredient.getItemType(), ingredient.getData());
164  }
ShapelessRecipe removeIngredient(Material ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.removeIngredient ( Material  ingredient,
int  rawdata 
)

Removes an ingredient from the list. If the ingredient occurs multiple times, only one instance of it is removed. If the data value is -1, only ingredients with a -1 data value will be removed.

Parameters
ingredientThe ingredient to remove
rawdataThe data value;
Returns
The changed recipe.
Deprecated:
Magic value

Definition at line 177 of file ShapelessRecipe.java.

References org.bukkit.inventory.ShapelessRecipe.removeIngredient().

177  {
178  return removeIngredient(1, ingredient, rawdata);
179  }
ShapelessRecipe removeIngredient(Material ingredient)
ShapelessRecipe org.bukkit.inventory.ShapelessRecipe.removeIngredient ( int  count,
Material  ingredient,
int  rawdata 
)

Removes multiple instances of an ingredient from the list. If there are less instances then specified, all will be removed. If the data value is -1, only ingredients with a -1 data value will be removed.

Parameters
countThe number of copies to remove.
ingredientThe ingredient to remove.
rawdataThe data value.
Returns
The changed recipe.
Deprecated:
Magic value

Definition at line 193 of file ShapelessRecipe.java.

References org.bukkit.inventory.ItemStack.getDurability(), and org.bukkit.inventory.ItemStack.getType().

193  {
194  Iterator<ItemStack> iterator = ingredients.iterator();
195  while (count > 0 && iterator.hasNext()) {
196  ItemStack stack = iterator.next();
197  if (stack.getType() == ingredient && stack.getDurability() == rawdata) {
198  iterator.remove();
199  count--;
200  }
201  }
202  return this;
203  }

The documentation for this class was generated from the following file: