@Override public void updateEntity() { if (internalPlayer == null) { internalInventoryCrafting = new InternalInventoryCrafting(); internalPlayer = new InternalPlayer(); craftSlot = new SlotCrafting(internalPlayer, internalInventoryCrafting, craftResult, 0, 0, 0); updateRecipe(); } if (!!worldObj.isRemote) return; if (lastMode == ActionMachineControl.Mode.Off) return; updateRecipe(); searchNeighborsForIngredients(); locateAndBindIngredients(); updateRecipeOutputDisplay(); justCrafted = false; if (canCraftAndOutput()) { if (getEnergy() >= getRequiredEnergy()) { craftItem(); justCrafted = true; } } else { craftable = false; internalInventoryCrafting.tempStacks = null; internalInventoryCrafting.hitCount = null; setEnergy(0); } }
private void locateAndBindIngredients() { internalInventoryCrafting.tempStacks = new InventoryCopy(inv).getItemStacks(); internalInventoryCrafting.hitCount = new int[internalInventoryCrafting.tempStacks.length]; ItemStack[] inputSlots = internalInventoryCrafting.tempStacks; for (int gridSlot = 0; gridSlot < craftingSlots.getSizeInventory(); gridSlot++) { internalInventoryCrafting.bindings[gridSlot] = -1; if (craftingSlots.getStackInSlot(gridSlot) == null) continue; boolean foundMatch = false; for (int inputSlot = 0; inputSlot < inputSlots.length; inputSlot++) { if (!isMatchingIngredient(gridSlot, inputSlot)) continue; if (internalInventoryCrafting.hitCount[inputSlot] < inputSlots[inputSlot].stackSize && internalInventoryCrafting.hitCount[inputSlot] < inputSlots[inputSlot].getMaxStackSize()) { internalInventoryCrafting.bindings[gridSlot] = inputSlot; internalInventoryCrafting.hitCount[inputSlot]++; foundMatch = true; break; } } if (!foundMatch) return; } }