001 package org.bukkit.inventory;
002
003 import org.bukkit.Material;
004 import org.bukkit.material.MaterialData;
005
006 /**
007 * Represents a smelting recipe.
008 */
009 public class FurnaceRecipe implements Recipe {
010 private ItemStack output;
011 private ItemStack ingredient;
012
013 /**
014 * Create a furnace recipe to craft the specified ItemStack.
015 *
016 * @param result The item you want the recipe to create.
017 * @param source The input material.
018 */
019 public FurnaceRecipe(ItemStack result, Material source) {
020 this(result, source, 0);
021 }
022
023 /**
024 * Create a furnace recipe to craft the specified ItemStack.
025 *
026 * @param result The item you want the recipe to create.
027 * @param source The input material.
028 */
029 public FurnaceRecipe(ItemStack result, MaterialData source) {
030 this(result, source.getItemType(), source.getData());
031 }
032
033 /**
034 * Create a furnace recipe to craft the specified ItemStack.
035 *
036 * @param result The item you want the recipe to create.
037 * @param source The input material.
038 * @param data The data value. (Note: This is currently ignored by the
039 * CraftBukkit server.)
040 * @deprecated Magic value
041 */
042 @Deprecated
043 public FurnaceRecipe(ItemStack result, Material source, int data) {
044 this.output = new ItemStack(result);
045 this.ingredient = new ItemStack(source, 1, (short) data);
046 }
047
048 /**
049 * Sets the input of this furnace recipe.
050 *
051 * @param input The input material.
052 * @return The changed recipe, so you can chain calls.
053 */
054 public FurnaceRecipe setInput(MaterialData input) {
055 return setInput(input.getItemType(), input.getData());
056 }
057
058 /**
059 * Sets the input of this furnace recipe.
060 *
061 * @param input The input material.
062 * @return The changed recipe, so you can chain calls.
063 */
064 public FurnaceRecipe setInput(Material input) {
065 return setInput(input, 0);
066 }
067
068 /**
069 * Sets the input of this furnace recipe.
070 *
071 * @param input The input material.
072 * @param data The data value. (Note: This is currently ignored by the
073 * CraftBukkit server.)
074 * @return The changed recipe, so you can chain calls.
075 * @deprecated Magic value
076 */
077 @Deprecated
078 public FurnaceRecipe setInput(Material input, int data) {
079 this.ingredient = new ItemStack(input, 1, (short) data);
080 return this;
081 }
082
083 /**
084 * Get the input material.
085 *
086 * @return The input material.
087 */
088 public ItemStack getInput() {
089 return this.ingredient.clone();
090 }
091
092 /**
093 * Get the result of this recipe.
094 *
095 * @return The resulting stack.
096 */
097 public ItemStack getResult() {
098 return output.clone();
099 }
100 }