public abstract class FluidHandler extends UpdatingTile implements net.minecraftforge.fluids.capability.IFluidHandler
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
SIZE_NBT_TAG |
protected static java.lang.String |
TANK_ID_NBT_TAG |
net.minecraftforge.fluids.FluidTank[] |
tanks |
protected static java.lang.String |
TANKS_NBT_TAG |
Constructor and Description |
---|
FluidHandler(net.minecraft.tileentity.TileEntityType<?> type)
Default constructor, calls the setupTanks method to setup the tanks
|
Modifier and Type | Method and Description |
---|---|
int |
bucketsToMB(int buckets)
Used to convert a number of buckets into MB
|
protected boolean |
canDrain(net.minecraftforge.fluids.Fluid fluid)
Returns true if the given fluid can be extracted
More formally, this should return true if fluid is able to leave
|
protected boolean |
canFill(net.minecraftforge.fluids.Fluid fluid)
Returns true if the given fluid can be inserted
More formally, this should return true if fluid is able to enter
|
net.minecraftforge.fluids.FluidStack |
drain(net.minecraftforge.fluids.FluidStack resource,
boolean doDrain)
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
|
net.minecraftforge.fluids.FluidStack |
drain(int maxDrain,
boolean doDrain)
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
|
int |
fill(net.minecraftforge.fluids.FluidStack resource,
boolean doFill)
Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.
|
<T> net.minecraftforge.common.util.LazyOptional<T> |
getCapability(net.minecraftforge.common.capabilities.Capability<T> capability,
net.minecraft.util.Direction facing) |
protected abstract int[] |
getInputTanks()
Which tanks can input
|
protected abstract int[] |
getOutputTanks()
Which tanks can output
|
net.minecraftforge.fluids.capability.IFluidTankProperties[] |
getTankProperties()
Returns an array of objects which represent the internal tanks.
|
void |
onTankChanged(net.minecraftforge.fluids.FluidTank tank)
Called when something happens to the tank, you should mark the block for update here if a tile
|
void |
read(net.minecraft.nbt.CompoundNBT compound)
Used to read from an NBT tag
|
protected abstract void |
setupTanks()
Used to set up the tanks needed.
|
net.minecraft.nbt.CompoundNBT |
write(net.minecraft.nbt.CompoundNBT compound)
Used to save the object to an NBT tag
|
getUpdatePacket, getUpdateTag, markForUpdate, onClientTick, onDataPacket, onServerTick, tick
addInfoToCrashReport, create, getBlockState, getDistanceSq, getMaxRenderDistanceSquared, getPos, getTileData, getType, getWorld, hasWorld, isRemoved, markDirty, mirror, onlyOpsCanSetNbt, receiveClientEvent, remove, rotate, setPos, setWorld, updateContainingBlockInfo, validate, warnInvalidBlock
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, getCapabilities, invalidateCaps, reviveCaps, serializeCaps
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected static final java.lang.String SIZE_NBT_TAG
protected static final java.lang.String TANK_ID_NBT_TAG
protected static final java.lang.String TANKS_NBT_TAG
public net.minecraftforge.fluids.FluidTank[] tanks
public FluidHandler(net.minecraft.tileentity.TileEntityType<?> type)
protected abstract void setupTanks()
protected abstract int[] getInputTanks()
protected abstract int[] getOutputTanks()
public void onTankChanged(net.minecraftforge.fluids.FluidTank tank)
public int bucketsToMB(int buckets)
buckets
- How many bucketsprotected boolean canFill(net.minecraftforge.fluids.Fluid fluid)
protected boolean canDrain(net.minecraftforge.fluids.Fluid fluid)
public net.minecraft.nbt.CompoundNBT write(net.minecraft.nbt.CompoundNBT compound)
write
in class net.minecraft.tileentity.TileEntity
compound
- The tag to save topublic void read(net.minecraft.nbt.CompoundNBT compound)
read
in class net.minecraft.tileentity.TileEntity
compound
- The tag to read frompublic <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.Direction facing)
getCapability
in interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
in class net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.tileentity.TileEntity>
public net.minecraftforge.fluids.capability.IFluidTankProperties[] getTankProperties()
getTankProperties
in interface net.minecraftforge.fluids.capability.IFluidHandler
public int fill(net.minecraftforge.fluids.FluidStack resource, boolean doFill)
fill
in interface net.minecraftforge.fluids.capability.IFluidHandler
resource
- FluidStack representing the Fluid and maximum amount of fluid to be filled.doFill
- If false, fill will only be simulated.@Nullable public net.minecraftforge.fluids.FluidStack drain(int maxDrain, boolean doDrain)
drain
in interface net.minecraftforge.fluids.capability.IFluidHandler
maxDrain
- Maximum amount of fluid to drain.doDrain
- If false, drain will only be simulated.@Nullable public net.minecraftforge.fluids.FluidStack drain(net.minecraftforge.fluids.FluidStack resource, boolean doDrain)
drain
in interface net.minecraftforge.fluids.capability.IFluidHandler
resource
- FluidStack representing the Fluid and maximum amount of fluid to be drained.doDrain
- If false, drain will only be simulated.