@Override public void updateEntity() { if (pos == 4 && !worldObj.isRemote && this.outputStack == null && storageAmount > 0 && identStack != null) this.markDirty(); if (pos == 4 && !worldObj.isRemote && this.outputStack != null && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && worldObj.getTotalWorldTime() % 8 == 0) { updateComparatorValuesPart1(); for (int i = 0; i < 6; i++) if (i != 1) { TileEntity inventory = this.worldObj.getTileEntity( xCoord + (i == 4 ? -1 : i == 5 ? 1 : 0), yCoord + (i == 0 ? -1 : 0), zCoord + (i == 2 ? -1 : i == 3 ? 1 : 0)); ItemStack stack = Utils.copyStackWithAmount(identStack, 1); if ((inventory instanceof ISidedInventory && ((ISidedInventory) inventory) .getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[i]) .length > 0) || (inventory instanceof IInventory && ((IInventory) inventory).getSizeInventory() > 0)) stack = Utils.insertStackIntoInventory( (IInventory) inventory, stack, ForgeDirection.OPPOSITES[i]); if (stack == null) { outputStack.stackSize--; this.markDirty(); if (outputStack == null) break; } } updateComparatorValuesPart2(); } }
@Override public void updateEntity() { if (!formed || pos != 4) return; if (worldObj.isRemote) return; boolean update = false; int consumed = Config.getInt("bottlingMachine_consumption"); for (int i = 0; i < inventory.length; i++) if (inventory[i] != null) { if (this.energyStorage.extractEnergy(consumed, true) == consumed) { this.energyStorage.extractEnergy(consumed, false); if (process[i]++ <= 72) { ItemStack filled = getFilledItem(inventory[i], false); if (predictedOutput[i] == null || !OreDictionary.itemMatches(filled, predictedOutput[i], true)) predictedOutput[i] = filled; if (process[i] == 1) update = true; if (filled != null && process[i] > 72) inventory[i] = getFilledItem(inventory[i], true).copy(); } } if (process[i] > 120) { ItemStack output = inventory[i].copy(); TileEntity invOutput = worldObj.getTileEntity( xCoord + (facing == 4 ? 1 : facing == 5 ? -1 : ((mirrored ? -1 : 1) * (facing == 3 ? 1 : -1))), yCoord + 1, zCoord + (facing == 2 ? 1 : facing == 3 ? -1 : ((mirrored ? -1 : 1) * (facing == 4 ? 1 : -1)))); if ((invOutput instanceof ISidedInventory && ((ISidedInventory) invOutput).getAccessibleSlotsFromSide(facing).length > 0) || (invOutput instanceof IInventory && ((IInventory) invOutput).getSizeInventory() > 0)) output = Utils.insertStackIntoInventory((IInventory) invOutput, output, facing); if (output != null) { ForgeDirection fd = ForgeDirection.getOrientation(facing); EntityItem ei = new EntityItem( worldObj, xCoord + .5 + (facing == 4 ? 1 : facing == 5 ? -1 : ((mirrored ? -1 : 1) * (facing == 3 ? 1 : -1))), yCoord + 1 + .25, zCoord + .5 + (facing == 2 ? 1 : facing == 3 ? -1 : ((mirrored ? -1 : 1) * (facing == 4 ? 1 : -1))), output.copy()); ei.motionX = (0.075F * fd.offsetX); ei.motionY = 0.025000000372529D; ei.motionZ = (0.075F * fd.offsetZ); this.worldObj.spawnEntityInWorld(ei); } process[i] = -1; inventory[i] = null; predictedOutput[i] = null; update = true; } } if (update) { this.markDirty(); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } }