@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;
  }
  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);
        }
      }
    }
  }