public class FluidTank extends java.lang.Object implements IFluidTank, IFluidHandler
IFluidTank
. Use/extend this or implement your own.Modifier and Type | Field and Description |
---|---|
protected boolean |
canDrain |
protected boolean |
canFill |
protected int |
capacity |
protected FluidStack |
fluid |
protected IFluidTankProperties[] |
tankProperties |
protected TileEntity |
tile |
Constructor and Description |
---|
FluidTank(Fluid fluid,
int amount,
int capacity) |
FluidTank(FluidStack fluidStack,
int capacity) |
FluidTank(int capacity) |
Modifier and Type | Method and Description |
---|---|
boolean |
canDrain()
Whether this tank can be drained with
IFluidHandler |
boolean |
canDrainFluidType(FluidStack fluid)
Returns true if the tank can drain out this type of fluid.
|
boolean |
canFill()
Whether this tank can be filled with
IFluidHandler |
boolean |
canFillFluidType(FluidStack fluid)
Returns true if the tank can be filled with this type of fluid.
|
FluidStack |
drain(FluidStack resource,
boolean doDrain)
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
|
FluidStack |
drain(int maxDrain,
boolean doDrain)
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
|
FluidStack |
drainInternal(FluidStack resource,
boolean doDrain)
Use this method to bypass the restrictions from
canDrainFluidType(FluidStack)
Meant for use by the owner of the tank when they have canDrain() set to false}. |
FluidStack |
drainInternal(int maxDrain,
boolean doDrain)
Use this method to bypass the restrictions from
canDrainFluidType(FluidStack)
Meant for use by the owner of the tank when they have canDrain() set to false}. |
int |
fill(FluidStack resource,
boolean doFill)
Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.
|
int |
fillInternal(FluidStack resource,
boolean doFill)
Use this method to bypass the restrictions from
canFillFluidType(FluidStack)
Meant for use by the owner of the tank when they have set to false . |
int |
getCapacity() |
FluidStack |
getFluid() |
int |
getFluidAmount() |
FluidTankInfo |
getInfo()
Returns a wrapper object
FluidTankInfo containing the capacity of the tank and the
FluidStack it holds. |
IFluidTankProperties[] |
getTankProperties()
Returns an array of objects which represent the internal tanks.
|
protected void |
onContentsChanged() |
FluidTank |
readFromNBT(NBTTagCompound nbt) |
void |
setCanDrain(boolean canDrain)
Set whether this tank can be drained with
IFluidHandler |
void |
setCanFill(boolean canFill)
Set whether this tank can be filled with
IFluidHandler |
void |
setCapacity(int capacity) |
void |
setFluid(FluidStack fluid) |
void |
setTileEntity(TileEntity tile) |
NBTTagCompound |
writeToNBT(NBTTagCompound nbt) |
@Nullable protected FluidStack fluid
protected int capacity
protected TileEntity tile
protected boolean canFill
protected boolean canDrain
protected IFluidTankProperties[] tankProperties
public FluidTank(int capacity)
public FluidTank(@Nullable FluidStack fluidStack, int capacity)
public FluidTank(Fluid fluid, int amount, int capacity)
public FluidTank readFromNBT(NBTTagCompound nbt)
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
@Nullable public FluidStack getFluid()
getFluid
in interface IFluidTank
public void setFluid(@Nullable FluidStack fluid)
public int getFluidAmount()
getFluidAmount
in interface IFluidTank
public int getCapacity()
getCapacity
in interface IFluidTank
public void setCapacity(int capacity)
public void setTileEntity(TileEntity tile)
public FluidTankInfo getInfo()
IFluidTank
FluidTankInfo
containing the capacity of the tank and the
FluidStack it holds.
Should prevent manipulation of the IFluidTank. See FluidTank
.getInfo
in interface IFluidTank
public IFluidTankProperties[] getTankProperties()
IFluidHandler
getTankProperties
in interface IFluidHandler
public int fill(FluidStack resource, boolean doFill)
IFluidHandler
fill
in interface IFluidHandler
fill
in interface IFluidTank
resource
- FluidStack attempting to fill the tank.doFill
- If false, the fill will only be simulated.public int fillInternal(FluidStack resource, boolean doFill)
canFillFluidType(FluidStack)
Meant for use by the owner of the tank when they have set to false
.public FluidStack drain(FluidStack resource, boolean doDrain)
IFluidHandler
drain
in interface IFluidHandler
resource
- FluidStack representing the Fluid and maximum amount of fluid to be drained.doDrain
- If false, drain will only be simulated.public FluidStack drain(int maxDrain, boolean doDrain)
IFluidHandler
drain
in interface IFluidHandler
drain
in interface IFluidTank
maxDrain
- Maximum amount of fluid to be removed from the container.doDrain
- If false, the drain will only be simulated.@Nullable public FluidStack drainInternal(FluidStack resource, boolean doDrain)
canDrainFluidType(FluidStack)
Meant for use by the owner of the tank when they have canDrain()
set to false}.@Nullable public FluidStack drainInternal(int maxDrain, boolean doDrain)
canDrainFluidType(FluidStack)
Meant for use by the owner of the tank when they have canDrain()
set to false}.public boolean canFill()
IFluidHandler
IFluidTankProperties.canFill()
public boolean canDrain()
IFluidHandler
IFluidTankProperties.canDrain()
public void setCanFill(boolean canFill)
IFluidHandler
IFluidTankProperties.canFill()
public void setCanDrain(boolean canDrain)
IFluidHandler
IFluidTankProperties.canDrain()
public boolean canFillFluidType(FluidStack fluid)
public boolean canDrainFluidType(@Nullable FluidStack fluid)
protected void onContentsChanged()