public static final void increaseStackQuantity(ItemStack itemStack, int quantity) { if (itemStack.getItem() instanceof IFood) { IFood food = (IFood) itemStack.getItem(); float newQuantity = food.getFoodWeight(itemStack) + quantity; Food.setWeight(itemStack, newQuantity); } else itemStack.stackSize += quantity; }
public boolean processItem() { if (storage[0] != null) { QuernRecipe qr = QuernManager.getInstance().findMatchingRecipe(storage[0]); if (qr == null) { TerraFirmaCraft.LOG.warn( "QUERN RECIPE NOT FOUND! This is a BUG! -- " + storage[0].getItem().getUnlocalizedName()); return false; // If this happens, it's a bug! } // If the output item can not be combined or is different from what is being made, eject and // make room for the new output if (storage[1] != null && !(storage[1].getItem() == qr.getResult().getItem() && storage[1].getItemDamage() == qr.getResult().getItemDamage())) { ejectItem(storage[1]); storage[1] = null; } if (qr.getInItem().getItem() instanceof IFood) { if (storage[1] != null) { float slot0Weight = Food.getWeight(storage[0]); float slot1Weight = Food.getWeight(storage[1]); float newWeight = slot0Weight + slot1Weight; if (newWeight > Global.FOOD_MAX_WEIGHT) { Food.setWeight(storage[1], newWeight - Global.FOOD_MAX_WEIGHT); ItemStack tossStack = storage[1].copy(); Food.setWeight(tossStack, Global.FOOD_MAX_WEIGHT); ejectItem(tossStack); } else { Food.setWeight(storage[1], newWeight); } storage[0] = null; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); return true; } if (storage[1] == null) { storage[1] = qr.getResult().copy(); float flourWeight = Food.getWeight(storage[0]); float flourDecay = Food.getDecay(storage[0]); ItemFoodTFC.createTag(storage[1], flourWeight, flourDecay); storage[0] = null; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); return true; } } else { if (storage[0].stackSize == qr.getInItem().stackSize) { storage[0] = null; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } else storage[0].stackSize -= qr.getInItem().stackSize; if (storage[1] == null) storage[1] = qr.getResult().copy(); else if (storage[1].stackSize < storage[1].getMaxStackSize()) { if ((qr.getResult().stackSize + storage[1].stackSize) > storage[1].getMaxStackSize()) { int amountleft = qr.getResult().stackSize - (storage[1].getMaxStackSize() - storage[1].stackSize); ItemStack tossStack = qr.getResult().copy(); tossStack.stackSize = tossStack.getMaxStackSize(); ejectItem(tossStack); ItemStack remainStack = qr.getResult().copy(); remainStack.stackSize = amountleft; storage[1] = remainStack; } else storage[1].stackSize += qr.getResult().stackSize; } else { ejectItem(storage[1]); storage[1] = qr.getResult().copy(); } return true; } } return false; }