Class FluidTank

java.lang.Object
net.neoforged.neoforge.fluids.capability.templates.FluidTank
All Implemented Interfaces:
ValueIOSerializable, IFluidHandler, IFluidTank

@Deprecated(since="1.21.9", forRemoval=true) public class FluidTank extends Object implements IFluidHandler, IFluidTank, ValueIOSerializable
Deprecated, for removal: This API element is subject to removal in a future version.
Flexible implementation of a Fluid Storage object. NOT REQUIRED.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface IFluidHandler

    IFluidHandler.FluidAction
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected FluidStack
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    FluidTank(int capacity)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    FluidTank(int capacity, Predicate<FluidStack> validator)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    drain(int maxDrain, IFluidHandler.FluidAction action)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    getFluidInTank(int tank)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the FluidStack in a given tank.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int
    getTankCapacity(int tank)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Retrieves the maximum fluid amount for a given tank.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the number of fluid storage units ("tanks") available
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    boolean
    isFluidValid(int tank, FluidStack stack)
    Deprecated, for removal: This API element is subject to removal in a future version.
    This function is a way to determine which fluids can exist inside a given handler.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    setCapacity(int capacity)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • validator

      protected Predicate<FluidStack> validator
      Deprecated, for removal: This API element is subject to removal in a future version.
    • fluid

      protected FluidStack fluid
      Deprecated, for removal: This API element is subject to removal in a future version.
    • capacity

      protected int capacity
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • FluidTank

      public FluidTank(int capacity)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • FluidTank

      public FluidTank(int capacity, Predicate<FluidStack> validator)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • setCapacity

      public FluidTank setCapacity(int capacity)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setValidator

      public FluidTank setValidator(Predicate<FluidStack> validator)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • isFluidValid

      public boolean isFluidValid(FluidStack stack)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      isFluidValid in interface IFluidTank
      Parameters:
      stack - Fluidstack holding the Fluid to be queried.
      Returns:
      If the tank can hold the fluid (EVER, not at the time of query).
    • getCapacity

      public int getCapacity()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      getCapacity in interface IFluidTank
      Returns:
      Capacity of this fluid tank.
    • getFluid

      public FluidStack getFluid()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      getFluid in interface IFluidTank
      Returns:
      FluidStack representing the fluid in the tank, null if the tank is empty.
    • getFluidAmount

      public int getFluidAmount()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      getFluidAmount in interface IFluidTank
      Returns:
      Current amount of fluid in the tank.
    • deserialize

      public void deserialize(ValueInput input)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      deserialize in interface ValueIOSerializable
    • serialize

      public void serialize(ValueOutput output)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      serialize in interface ValueIOSerializable
    • getTanks

      public int getTanks()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IFluidHandler
      Returns the number of fluid storage units ("tanks") available
      Specified by:
      getTanks in interface IFluidHandler
      Returns:
      The number of tanks available
    • getFluidInTank

      public FluidStack getFluidInTank(int tank)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IFluidHandler
      Returns the FluidStack in a given tank.

      IMPORTANT: This FluidStack MUST NOT be modified. This method is not for altering internal contents. Any implementers who are able to detect modification via this method should throw an exception. It is ENTIRELY reasonable and likely that the stack returned here will be a copy.

      SERIOUSLY: DO NOT MODIFY THE RETURNED FLUIDSTACK

      Specified by:
      getFluidInTank in interface IFluidHandler
      Parameters:
      tank - Tank to query.
      Returns:
      FluidStack in a given tank. FluidStack.EMPTY if the tank is empty.
    • getTankCapacity

      public int getTankCapacity(int tank)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IFluidHandler
      Retrieves the maximum fluid amount for a given tank.
      Specified by:
      getTankCapacity in interface IFluidHandler
      Parameters:
      tank - Tank to query.
      Returns:
      The maximum fluid amount held by the tank.
    • isFluidValid

      public boolean isFluidValid(int tank, FluidStack stack)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IFluidHandler
      This function is a way to determine which fluids can exist inside a given handler. General purpose tanks will basically always return TRUE for this.
      Specified by:
      isFluidValid in interface IFluidHandler
      Parameters:
      tank - Tank to query for validity
      stack - Stack to test with for validity
      Returns:
      TRUE if the tank can hold the FluidStack, not considering current state. (Basically, is a given fluid EVER allowed in this tank?) Return FALSE if the answer to that question is 'no.'
    • fill

      public int fill(FluidStack resource, IFluidHandler.FluidAction action)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IFluidHandler
      Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.
      Specified by:
      fill in interface IFluidHandler
      Specified by:
      fill in interface IFluidTank
      Parameters:
      resource - FluidStack representing the Fluid and maximum amount of fluid to be filled.
      action - If SIMULATE, fill will only be simulated.
      Returns:
      Amount of resource that was (or would have been, if simulated) filled.
    • drain

      public FluidStack drain(FluidStack resource, IFluidHandler.FluidAction action)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IFluidHandler
      Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
      Specified by:
      drain in interface IFluidHandler
      Specified by:
      drain in interface IFluidTank
      Parameters:
      resource - FluidStack representing the Fluid and maximum amount of fluid to be drained.
      action - If SIMULATE, drain will only be simulated.
      Returns:
      FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained.
    • drain

      public FluidStack drain(int maxDrain, IFluidHandler.FluidAction action)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IFluidHandler
      Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.

      This method is not Fluid-sensitive.

      Specified by:
      drain in interface IFluidHandler
      Specified by:
      drain in interface IFluidTank
      Parameters:
      maxDrain - Maximum amount of fluid to drain.
      action - If SIMULATE, drain will only be simulated.
      Returns:
      FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained.
    • onContentsChanged

      protected void onContentsChanged()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setFluid

      public void setFluid(FluidStack stack)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • isEmpty

      public boolean isEmpty()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getSpace

      public int getSpace()
      Deprecated, for removal: This API element is subject to removal in a future version.