Exemplo n.º 1
0
        public virtual ItemStack FindMatchingRecipe(InventoryCrafting par1InventoryCrafting)
        {
            int       i          = 0;
            ItemStack itemstack  = null;
            ItemStack itemstack1 = null;

            for (int j = 0; j < par1InventoryCrafting.GetSizeInventory(); j++)
            {
                ItemStack itemstack2 = par1InventoryCrafting.GetStackInSlot(j);

                if (itemstack2 == null)
                {
                    continue;
                }

                if (i == 0)
                {
                    itemstack = itemstack2;
                }

                if (i == 1)
                {
                    itemstack1 = itemstack2;
                }

                i++;
            }

            if (i == 2 && itemstack.ItemID == itemstack1.ItemID && itemstack.StackSize == 1 && itemstack1.StackSize == 1 && Item.ItemsList[itemstack.ItemID].IsDamageable())
            {
                Item item = Item.ItemsList[itemstack.ItemID];
                int  l    = item.GetMaxDamage() - itemstack.GetItemDamageForDisplay();
                int  i1   = item.GetMaxDamage() - itemstack1.GetItemDamageForDisplay();
                int  j1   = l + i1 + (item.GetMaxDamage() * 10) / 100;
                int  k1   = item.GetMaxDamage() - j1;

                if (k1 < 0)
                {
                    k1 = 0;
                }

                return(new ItemStack(itemstack.ItemID, 1, k1));
            }

            for (int k = 0; k < Recipes.Count; k++)
            {
                IRecipe irecipe = (IRecipe)Recipes[k];

                if (irecipe.Matches(par1InventoryCrafting))
                {
                    return(irecipe.GetCraftingResult(par1InventoryCrafting));
                }
            }

            return(null);
        }