2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.library.crafting;
|
|
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
import java.util.*;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.item.crafting.ShapelessRecipes;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.world.World;
|
2015-05-10 13:10:34 +02:00
|
|
|
import net.minecraftforge.oredict.RecipeSorter;
|
|
|
|
|
import tconstruct.TConstruct;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.library.tools.ToolCore;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
public class ShapelessToolRecipe extends ShapelessRecipes
|
|
|
|
|
{
|
2015-05-10 13:10:34 +02:00
|
|
|
static {
|
|
|
|
|
RecipeSorter.register(TConstruct.modID + ":" + "toolrecipe", ShapelessToolRecipe.class, RecipeSorter.Category.SHAPELESS, "");
|
|
|
|
|
}
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
public ShapelessToolRecipe(ItemStack par1ItemStack, List par2List)
|
|
|
|
|
{
|
|
|
|
|
super(par1ItemStack, par2List);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean matches (InventoryCrafting par1InventoryCrafting, World par2World)
|
|
|
|
|
{
|
|
|
|
|
ArrayList arraylist = new ArrayList(this.recipeItems);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < 3; ++j)
|
|
|
|
|
{
|
|
|
|
|
ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i);
|
|
|
|
|
|
|
|
|
|
if (itemstack != null)
|
|
|
|
|
{
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
Iterator iterator = arraylist.iterator();
|
|
|
|
|
|
|
|
|
|
while (iterator.hasNext())
|
|
|
|
|
{
|
2014-09-09 18:30:15 +10:00
|
|
|
ItemStack itemstack1 = (ItemStack) iterator.next();
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// TConstruct.logger.info("Rawr! "+itemstack1.getItemDamage());
|
2014-10-06 10:05:54 +02:00
|
|
|
if (itemstack.getItem() == itemstack1.getItem())
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
if (itemstack.getItem() instanceof ToolCore)
|
|
|
|
|
{
|
|
|
|
|
NBTTagCompound tags = itemstack.getTagCompound().getCompoundTag("InfiTool");
|
|
|
|
|
if (tags.getBoolean("Broken"))
|
|
|
|
|
return false;
|
2014-10-06 10:05:54 +02:00
|
|
|
|
|
|
|
|
flag = true;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2014-10-06 10:05:54 +02:00
|
|
|
else if((itemstack1.getItemDamage() == Short.MAX_VALUE || itemstack.getItemDamage() == itemstack1.getItemDamage()))
|
|
|
|
|
flag = true;
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
arraylist.remove(itemstack1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return arraylist.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|