So is it working ? I think the recipe bit should be a bit shorter but I'm just doing it from reading. Like in recipes indexof crafting icon name + column should be enough and the column would be different for item 2. If you have done recipe in the format (name,ingredientA,quantity,ingredientB,quantity) columns would be 2 and 4 for example.
Also for quantity where you're subtracting it looks ok except don't look for index of the items as they may appear in more than one recipe, always look for the index of the item name you are crafting which is the start of the recipe.