ItemStack[] crafting = (simulate ? this.crafting.clone() : this.crafting);
boolean success = true;
craftingLoop:
for (int i = 0; i < crafting.length; i++) {
ItemStack stack = crafting[i];
IRecipeInput required = requiredInput[i];
if (required != null) {
int currentAmount = 0;
if ((stack != null) && simulate)
stack = craftSlot(stack, required, null, true);
if (stack != null) {
if (!required.matches(stack)) return false;
currentAmount = stack.stackSize;
}
int requiredAmount = (required.getAmount() - currentAmount);
if (requiredAmount <= 0) continue;
for (int j = 0; j < contents.length; j++) {
ItemStack contentsStack = contents[j];
if (contentsStack == null) continue;
if ((stack == null) ? required.matches(contentsStack)
: StackUtils.matches(stack, contentsStack)) {
int amount = Math.min(contentsStack.stackSize, requiredAmount);
crafting[i] = stack = StackUtils.copyStack(contentsStack, (currentAmount += amount));
contents[j] = StackUtils.copyStack(contentsStack, contentsStack.stackSize - amount);
if ((requiredAmount -= amount) <= 0)