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); }
/// <summary> /// Used to check if a recipe matches current crafting inventory /// </summary> public virtual bool Matches(InventoryCrafting par1InventoryCrafting) { List <ItemStack> arraylist = new List <ItemStack>(RecipeItems); int i = 0; do { if (i >= 3) { break; } for (int j = 0; j < 3; j++) { ItemStack itemstack = par1InventoryCrafting.GetStackInRowAndColumn(j, i); if (itemstack == null) { continue; } bool flag = false; IEnumerator <ItemStack> iterator = arraylist.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } ItemStack itemstack1 = iterator.Current; if (itemstack.ItemID != itemstack1.ItemID || itemstack1.GetItemDamage() != -1 && itemstack.GetItemDamage() != itemstack1.GetItemDamage()) { continue; } flag = true; arraylist.Remove(itemstack1); break; }while (true); if (!flag) { return(false); } } i++; }while (true); return(arraylist.Count == 0); }
/// <summary> /// Returns an Item that is the result of this recipe /// </summary> public virtual ItemStack GetCraftingResult(InventoryCrafting par1InventoryCrafting) { return(RecipeOutput.Copy()); }