net.minecraftforge.fluids

## Class FluidTank

- java.lang.Object
- - net.minecraftforge.fluids.FluidTank

- All Implemented Interfaces:
    IFluidTank

      public class FluidTank
      extends Object
      implements IFluidTank

  Reference implementation of `IFluidTank`. Use/extend this or implement your own.
  Author:
    King Lemming, cpw (LiquidTank)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FluidTank(Fluid fluid, int amount, int capacity)`
    `FluidTank(FluidStack stack, int capacity)`
    `FluidTank(int capacity)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `FluidStack` | `drain(int maxDrain, boolean doDrain)`
    `int` | `fill(FluidStack resource, boolean doFill)`
    `int` | `getCapacity()`
    `FluidStack` | `getFluid()`
    `int` | `getFluidAmount()`
    `FluidTankInfo` | `getInfo()` Returns a wrapper object `FluidTankInfo` containing the capacity of the tank and the FluidStack it holds.
    `FluidTank` | `readFromNBT(NBTTagCompound nbt)`
    `void` | `setCapacity(int capacity)`
    `void` | `setFluid(FluidStack fluid)`
    `NBTTagCompound` | `writeToNBT(NBTTagCompound nbt)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FluidTank

          public FluidTank(int capacity)

    - #### FluidTank

          public FluidTank(FluidStack stack,
                   int capacity)

    - #### FluidTank

          public FluidTank(Fluid fluid,
                   int amount,
                   int capacity)

  - ### Method Detail

    - #### readFromNBT

          public FluidTank readFromNBT(NBTTagCompound nbt)

    - #### writeToNBT

          public NBTTagCompound writeToNBT(NBTTagCompound nbt)

    - #### setFluid

          public void setFluid(FluidStack fluid)

    - #### setCapacity

          public void setCapacity(int capacity)

    - #### getFluid

          public FluidStack getFluid()

      Specified by:
        `getFluid` in interface `IFluidTank`
      Returns:
        FluidStack representing the fluid in the tank, null if the tank is empty.

    - #### getFluidAmount

          public int getFluidAmount()

      Specified by:
        `getFluidAmount` in interface `IFluidTank`
      Returns:
        Current amount of fluid in the tank.

    - #### getCapacity

          public int getCapacity()

      Specified by:
        `getCapacity` in interface `IFluidTank`
      Returns:
        Capacity of this fluid tank.

    - #### getInfo

          public FluidTankInfo getInfo()

      Description copied from interface: `IFluidTank`
      Returns a wrapper object `FluidTankInfo` containing the capacity of the tank and the FluidStack it holds. Should prevent manipulation of the IFluidTank. See `FluidTank`.
      Specified by:
        `getInfo` in interface `IFluidTank`
      Returns:
        State information for the IFluidTank.

    - #### fill

          public int fill(FluidStack resource,
                 boolean doFill)

      Specified by:
        `fill` in interface `IFluidTank`
      Parameters:
        `resource` - FluidStack attempting to fill the tank.
        `doFill` - If false, the fill will only be simulated.
      Returns:
        Amount of fluid that was accepted by the tank.

    - #### drain

          public FluidStack drain(int maxDrain,
                         boolean doDrain)

      Specified by:
        `drain` in interface `IFluidTank`
      Parameters:
        `maxDrain` - Maximum amount of fluid to be removed from the container.
      Returns:
        Amount of fluid that was removed from the tank.