Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.inventory;
2
3import org.bukkit.Material;
4import org.bukkit.material.MaterialData;
5
6/**
7 * Represents a smelting recipe.
8 */
9public class FurnaceRecipe implements Recipe {
10 private ItemStack output;
11 private MaterialData ingredient;
12
13 /**
14 * Create a furnace recipe to craft the specified ItemStack.
15 *
16 * @param result The item you want the recipe to create.
17 * @param source The input material.
18 */
19 public FurnaceRecipe(ItemStack result, Material source) {
20 this(result, source.getNewData((byte) 0));
21 if (this.ingredient == null) {
22 setInput(new MaterialData(source));
23 }
24 }
25
26 /**
27 * Create a furnace recipe to craft the specified ItemStack.
28 *
29 * @param result The item you want the recipe to create.
30 * @param source The input material.
31 */
32 public FurnaceRecipe(ItemStack result, MaterialData source) {
33 this.output = result;
34 this.ingredient = source;
35 }
36
37 /**
38 * Sets the input of this furnace recipe.
39 *
40 * @param input The input material.
41 * @return The changed recipe, so you can chain calls.
42 */
43 public FurnaceRecipe setInput(MaterialData input) {
44 this.ingredient = input;
45 return this;
46 }
47
48 /**
49 * Sets the input of this furnace recipe.
50 *
51 * @param input The input material.
52 * @return The changed recipe, so you can chain calls.
53 */
54 public FurnaceRecipe setInput(Material input) {
55 setInput(input.getNewData((byte) 0));
56 if (this.ingredient == null) {
57 setInput(new MaterialData(input));
58 }
59 return this;
60 }
61
62 /**
63 * Get the input material.
64 *
65 * @return The input material.
66 */
67 public MaterialData getInput() {
68 return (MaterialData) ingredient;
69 }
70
71 /**
72 * Get the result of this recipe.
73 *
74 * @return The resulting stack.
75 */
76 public ItemStack getResult() {
77 return output;
78 }
79}