private void manageInventory() {
    if (FluidContainerUtils.isFluidContainer(inventory[0])) {
      FluidStack ret =
          FluidContainerUtils.handleContainerItem(
              this, inventory, editMode, fluidTank.getFluid(), getCurrentNeeded(), 0, 1, null);

      if (ret != null) {
        fluidTank.setFluid(PipeUtils.copy(ret, Math.min(fluidTank.getCapacity(), ret.amount)));

        int rejects = Math.max(0, ret.amount - fluidTank.getCapacity());

        if (rejects > 0) {
          pushUp(PipeUtils.copy(ret, rejects), true);
        }
      }
    }
  }
  @Override
  public boolean isItemValidForSlot(int slotID, ItemStack itemstack) {
    if (slotID == 0) {
      if (FluidContainerUtils.isFluidContainer(itemstack)) {
        return true;
      }
    }

    return false;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot currentSlot = (Slot) inventorySlots.get(slotID);

    if (currentSlot != null && currentSlot.getHasStack()) {
      ItemStack slotStack = currentSlot.getStack();
      stack = slotStack.copy();

      if (FluidContainerUtils.isFluidContainer(slotStack)) {
        if (slotID != 0 && slotID != 1) {
          if (!mergeItemStack(slotStack, 0, 1, false)) {
            return null;
          }
        } else {
          if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) {
            return null;
          }
        }
      } else {
        if (slotID >= 2 && slotID <= 28) {
          if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) {
            return null;
          }
        } else if (slotID > 28) {
          if (!mergeItemStack(slotStack, 2, 28, false)) {
            return null;
          }
        } else {
          if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) {
            return null;
          }
        }
      }

      if (slotStack.stackSize == 0) {
        currentSlot.putStack((ItemStack) null);
      } else {
        currentSlot.onSlotChanged();
      }

      if (slotStack.stackSize == stack.stackSize) {
        return null;
      }

      currentSlot.onPickupFromSlot(player, slotStack);
    }

    return stack;
  }
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (!worldObj.isRemote) {
      ChargeUtils.charge(1, this);

      if (inventory[0] != null) {
        FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);

        if (inventory[0].getItem() instanceof IFluidContainerItem) {
          lavaTank.fill(
              FluidContainerUtils.extractFluid(
                  lavaTank, inventory[0], FluidChecker.check(FluidRegistry.LAVA)),
              true);
        } else if (fluid != null) {
          if (fluid != null && fluid.getFluidID() == FluidRegistry.LAVA.getID()) {
            if (lavaTank.getFluid() == null
                || lavaTank.getFluid().amount + fluid.amount <= lavaTank.getCapacity()) {
              lavaTank.fill(fluid, true);

              if (inventory[0].getItem().getContainerItem(inventory[0]) != null) {
                inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]);
              } else {
                inventory[0].stackSize--;
              }

              if (inventory[0].stackSize == 0) {
                inventory[0] = null;
              }
            }
          }
        } else {
          int fuel = getFuel(inventory[0]);

          if (fuel > 0) {
            int fuelNeeded =
                lavaTank.getCapacity()
                    - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0);

            if (fuel <= fuelNeeded) {
              lavaTank.fill(new FluidStack(FluidRegistry.LAVA, fuel), true);

              if (inventory[0].getItem().getContainerItem(inventory[0]) != null) {
                inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]);
              } else {
                inventory[0].stackSize--;
              }

              if (inventory[0].stackSize == 0) {
                inventory[0] = null;
              }
            }
          }
        }
      }

      double prev = getEnergy();

      transferHeatTo(getBoost());

      if (canOperate()) {
        setActive(true);

        lavaTank.drain(10, true);
        transferHeatTo(generators.heatGeneration);
      } else {
        setActive(false);
      }

      double[] loss = simulateHeat();
      applyTemperatureChange();

      lastTransferLoss = loss[0];
      lastEnvironmentLoss = loss[1];

      producingEnergy = getEnergy() - prev;
    }
  }
  @Override
  public void onUpdate() {
    if (!worldObj.isRemote) {
      ChargeUtils.discharge(2, this);

      if (inventory[0] != null) {
        if (inventory[0].getItem() instanceof IFluidContainerItem
            && ((IFluidContainerItem) inventory[0].getItem()).getFluid(inventory[0]) != null) {
          if (((IFluidContainerItem) inventory[0].getItem())
              .getFluid(inventory[0])
              .getFluid()
              .canBePlacedInWorld()) {
            fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory[0]), true);

            if (((IFluidContainerItem) inventory[0].getItem()).getFluid(inventory[0]) == null
                || fluidTank.getFluidAmount() == fluidTank.getCapacity()) {
              if (inventory[1] == null) {
                inventory[1] = inventory[0].copy();
                inventory[0] = null;

                markDirty();
              }
            }
          }
        } else if (FluidContainerRegistry.isFilledContainer(inventory[0])) {
          FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);

          if ((fluidTank.getFluid() == null && itemFluid.amount <= fluidTank.getCapacity())
              || fluidTank.getFluid().amount + itemFluid.amount <= fluidTank.getCapacity()) {
            if ((fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))
                || !itemFluid.getFluid().canBePlacedInWorld()) {
              return;
            }

            ItemStack containerItem = inventory[0].getItem().getContainerItem(inventory[0]);

            boolean filled = false;

            if (containerItem != null) {
              if (inventory[1] == null
                  || (inventory[1].isItemEqual(containerItem)
                      && inventory[1].stackSize + 1 <= containerItem.getMaxStackSize())) {
                inventory[0] = null;

                if (inventory[1] == null) {
                  inventory[1] = containerItem;
                } else {
                  inventory[1].stackSize++;
                }

                filled = true;
              }
            } else {
              inventory[0].stackSize--;

              if (inventory[0].stackSize == 0) {
                inventory[0] = null;
              }

              filled = true;
            }

            if (filled) {
              fluidTank.fill(itemFluid, true);
              markDirty();
            }
          }
        }
      }

      if (getEnergy() >= usage.fluidicPlenisherUsage
          && worldObj.getWorldTime() % 10 == 0
          && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME) {
        if (fluidTank.getFluid().getFluid().canBePlacedInWorld()) {
          if (!finishedCalc) {
            doPlenish();
          } else {
            Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);

            if (canReplace(below, false, false)
                && getEnergy() >= usage.fluidicPlenisherUsage
                && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME) {
              if (fluidTank.getFluid().getFluid().canBePlacedInWorld()) {
                worldObj.setBlock(
                    below.xCoord,
                    below.yCoord,
                    below.zCoord,
                    MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()),
                    0,
                    3);

                setEnergy(getEnergy() - usage.fluidicPlenisherUsage);
                fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
              }
            }
          }
        }
      }
    }
  }