// because it makes Oak Wood Planks using the same recipe.
// Strategy:
// Create a fake crafting inventory using items we have in stock
// in place of the ones in the saved crafting inventory.
// Check that the recipe it makes is the same as the currentRecipe.
InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
ItemStack[] stockCopy = StackUtils.condenseStacks(stock);
for (int slot = 0; slot < currentCrafting.getSizeInventory(); slot++) {
ItemStack recipeStack = currentCrafting.getStackInSlot(slot);
if (recipeStack == null)
continue;
// Use crafting equivalent (not oredict) items first
for (ItemStack stockStack : stockCopy) {
if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, false, false)) {
ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
stockStack.stackSize--;
crafting.setInventorySlotContents(slot, stack);
break;
}
}
// Use oredict items if crafting equivalent items aren't available
if (crafting.getStackInSlot(slot) == null) {
for (ItemStack stockStack : stockCopy) {
if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, true, true)) {
ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage());
stockStack.stackSize--;
crafting.setInventorySlotContents(slot, stack);
break;
}
}
}
}