[Bleeding] Recipe API improvements and fixes. Addresses BUKKIT-738 and BUKKIT-624

Add a recipe iterator to make it possible to retrieve and remove recipes (BUKKIT-738), and updated the recipe classes to not clip the data to 127 (BUKKIT-624)
This commit is contained in:
Celtic Minstrel
2011-07-23 23:16:14 -04:00
committed by EvilSeph
parent 84ecdb5439
commit 326091c130
10 changed files with 227 additions and 33 deletions

View File

@@ -4,6 +4,12 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
import org.bukkit.inventory.ShapelessRecipe;
// CraftBukkit end
public class ShapelessRecipes implements CraftingRecipe {
private final ItemStack a;
@@ -14,6 +20,20 @@ public class ShapelessRecipes implements CraftingRecipe {
this.b = list;
}
// CraftBukkit start
@SuppressWarnings("unchecked")
public ShapelessRecipe toBukkitRecipe() {
CraftItemStack result = new CraftItemStack(this.a);
CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this);
for (ItemStack stack : (List<ItemStack>) this.b) {
if (stack != null) {
recipe.addIngredient(org.bukkit.Material.getMaterial(stack.id), stack.getData());
}
}
return recipe;
}
// CraftBukkit end
public ItemStack b() {
return this.a;
}