2011-07-15 02:54:07 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
|
2011-07-24 05:16:14 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public class ShapelessRecipes implements IRecipe {
|
2011-07-15 02:54:07 +02:00
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
private final ItemStack result;
|
|
|
|
private final List ingredients;
|
2011-07-15 02:54:07 +02:00
|
|
|
|
|
|
|
public ShapelessRecipes(ItemStack itemstack, List list) {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.result = itemstack;
|
|
|
|
this.ingredients = list;
|
2011-07-15 02:54:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-24 05:16:14 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
@SuppressWarnings("unchecked")
|
2012-07-22 08:18:00 +02:00
|
|
|
public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe() {
|
2012-12-17 08:31:41 +01:00
|
|
|
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
2011-07-24 05:16:14 +02:00
|
|
|
CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this);
|
2012-02-29 22:31:04 +01:00
|
|
|
for (ItemStack stack : (List<ItemStack>) this.ingredients) {
|
2011-07-24 05:16:14 +02:00
|
|
|
if (stack != null) {
|
|
|
|
recipe.addIngredient(org.bukkit.Material.getMaterial(stack.id), stack.getData());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return recipe;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-07-15 02:54:07 +02:00
|
|
|
public ItemStack b() {
|
2012-02-29 22:31:04 +01:00
|
|
|
return this.result;
|
2011-07-15 02:54:07 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean a(InventoryCrafting inventorycrafting, World world) {
|
2012-02-29 22:31:04 +01:00
|
|
|
ArrayList arraylist = new ArrayList(this.ingredients);
|
2011-07-15 02:54:07 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
for (int j = 0; j < 3; ++j) {
|
|
|
|
ItemStack itemstack = inventorycrafting.b(j, i);
|
|
|
|
|
|
|
|
if (itemstack != null) {
|
|
|
|
boolean flag = false;
|
|
|
|
Iterator iterator = arraylist.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
ItemStack itemstack1 = (ItemStack) iterator.next();
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (itemstack.id == itemstack1.id && (itemstack1.getData() == 32767 || itemstack.getData() == itemstack1.getData())) {
|
2011-07-15 02:54:07 +02:00
|
|
|
flag = true;
|
|
|
|
arraylist.remove(itemstack1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return arraylist.isEmpty();
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public ItemStack a(InventoryCrafting inventorycrafting) {
|
2012-02-29 22:31:04 +01:00
|
|
|
return this.result.cloneItemStack();
|
2011-07-15 02:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a() {
|
2012-02-29 22:31:04 +01:00
|
|
|
return this.ingredients.size();
|
2011-07-15 02:54:07 +02:00
|
|
|
}
|
|
|
|
}
|