Interface FluidContainer
- All Superinterfaces:
net.minecraft.world.Clearable,Serializable
- All Known Subinterfaces:
ItemFluidContainer
- All Known Implementing Classes:
ExtractOnlyFluidContainer,InsertOnlyFluidContainer,PlatformBlockFluidHandler,PlatformFluidItemHandler,SimpleFluidContainer,UnlimitedFluidContainer,WrappedBlockFluidContainer,WrappedItemFluidContainer
-
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleancopy()extractFluid(FluidHolder fluid, boolean simulate) Extracts aFluidHolderfrom the container.longextractFromSlot(FluidHolder fluidHolder, FluidHolder toInsert, Runnable snapshot) Extracts a fluid from oneFluidHolderinto another.voidfromContainer(FluidContainer container) Sets the container to the same values as the given container.default FluidHolderintgetSize()longgetTankCapacity(int tankSlot) static booleanholdsFluid(net.minecraft.world.item.ItemStack stack) Checks if the given item stack holds fluid.static booleanholdsFluid(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable net.minecraft.core.Direction direction) Checks if the given block entity holds fluid.static booleanholdsFluid(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction direction) Checks if the given block holds fluid.static booleanholdsFluid(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.level.block.state.BlockState state, @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable net.minecraft.core.Direction direction) Checks if the given block holds fluid.longinsertFluid(FluidHolder fluid, boolean simulate) Inserts aFluidHolderinto the container.default FluidHolderinternalExtract(FluidHolder fluid, boolean simulate) An internal version ofextractFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.default longinternalInsert(FluidHolder fluids, boolean simulate) An internal version ofinsertFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.booleanisEmpty()default booleanisFluidValid(int slot, FluidHolder fluidHolder) static @Nullable ItemFluidContainerof(ItemStackHolder holder) Retrieves an instance of FluidContainer for the given item stack.static @Nullable FluidContainerof(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable net.minecraft.core.Direction direction) Retrieves an instance of FluidContainer for the given block entity and direction.static @Nullable FluidContainerof(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction direction) Retrieves an instance of FluidContainer for the given level, position, and direction.static @Nullable FluidContainerof(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.level.block.state.BlockState state, @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable net.minecraft.core.Direction direction) Retrieves an instance of FluidContainer for the given level, position, state, entity, and direction.default voidreadSnapshot(FluidSnapshot snapshot) Sets theFluidContainerwith the given state ofFluidSnapshot.voidsetFluid(int slot, FluidHolder fluid) Sets a givenFluidHolderto a slot in the container.Methods inherited from interface net.minecraft.world.Clearable
clearContentMethods inherited from interface earth.terrarium.botarium.util.Serializable
deserialize, serialize
-
Method Details
-
of
@Nullable @ImplementedByExtension static @Nullable FluidContainer of(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.world.level.block.state.BlockState state, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable @Nullable net.minecraft.core.Direction direction) Retrieves an instance of FluidContainer for the given level, position, state, entity, and direction. This method can be used to retrieve FluidContainers from Botarium and any other mod that uses the modloader's Fluid API.- Parameters:
level- The level of the FluidContainer.pos- The position of the FluidContainer.state- The block state of the FluidContainer.entity- The block entity associated with the FluidContainer (can be null).direction- The direction of the FluidContainer (can be null).- Returns:
- An instance of FluidContainer. Returns null if the block does not hold fluid.
-
of
@Nullable static @Nullable FluidContainer of(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.core.Direction direction) Retrieves an instance of FluidContainer for the given level, position, and direction. This method can be used to retrieve FluidContainers from Botarium and any other mod that uses the modloader's Fluid API.- Parameters:
level- The level of the FluidContainer.pos- The position of the FluidContainer.direction- The direction of the FluidContainer (can be null).- Returns:
- An instance of FluidContainer. Returns null if the block does not hold fluid.
-
of
@Nullable static @Nullable FluidContainer of(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable @Nullable net.minecraft.core.Direction direction) Retrieves an instance of FluidContainer for the given block entity and direction. This method can be used to retrieve FluidContainers from Botarium and any other mod that uses the modloader's Fluid API.- Parameters:
block- The block entity associated with the FluidContainer.direction- The direction of the FluidContainer (can be null).- Returns:
- An instance of FluidContainer. Returns null if the block does not hold fluid.
-
of
Retrieves an instance of FluidContainer for the given item stack. This method can be used to retrieve FluidContainers from Botarium and any other mod that uses the modloader's Fluid API.- Parameters:
holder- The item stack associated with the FluidContainer.- Returns:
- An instance of FluidContainer. Returns null if the item does not hold fluid.
-
holdsFluid
@ImplementedByExtension static boolean holdsFluid(net.minecraft.world.item.ItemStack stack) Checks if the given item stack holds fluid.- Parameters:
stack- The item stack to check.- Returns:
- Whether the given item stack holds fluid.
-
holdsFluid
@ImplementedByExtension static boolean holdsFluid(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.world.level.block.state.BlockState state, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable @Nullable net.minecraft.core.Direction direction) Checks if the given block holds fluid.- Parameters:
level- The level of the block.pos- The position of the block.state- The block state of the block.entity- The block entity associated with the block (can be null).direction- The direction of the block (can be null).- Returns:
- Whether the given block holds fluid.
-
holdsFluid
static boolean holdsFluid(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.core.Direction direction) Checks if the given block holds fluid.- Parameters:
level- The level of the block.pos- The position of the block.direction- The direction of the block (can be null).- Returns:
- Whether the given block holds fluid.
-
holdsFluid
static boolean holdsFluid(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable @Nullable net.minecraft.core.Direction direction) Checks if the given block entity holds fluid.- Parameters:
block- The block entity to check.direction- The direction of the block entity (can be null).- Returns:
- Whether the given block entity holds fluid.
-
insertFluid
Inserts aFluidHolderinto the container.- Parameters:
fluid- TheFluidHolderto be inserted into the container.simulate- If true, the container will not be modified.- Returns:
- The amount of fluid that was added to the container.
-
internalInsert
An internal version ofinsertFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.You should not call this method for other mod's containers, instead use
insertFluid(FluidHolder, boolean). -
extractFluid
Extracts aFluidHolderfrom the container.- Parameters:
fluid- TheFluidHolderto be extracted from the container.simulate- If true, the container will not be modified.- Returns:
- The
FluidHolderthat was extracted from the container.
-
internalExtract
An internal version ofextractFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.You should not call this method for other mod's containers, instead use
extractFluid(FluidHolder, boolean). -
setFluid
Sets a givenFluidHolderto a slot in the container.- Parameters:
slot- The slot to set the fluid in.fluid- TheFluidHolderto set in the slot.
-
getFluids
List<FluidHolder> getFluids()- Returns:
- A
ListofFluidHolderin the container.
-
getSize
int getSize()- Returns:
- The amount of slots in the container.
-
isEmpty
boolean isEmpty()- Returns:
- Whether or not the container is empty.
-
copy
FluidContainer copy()- Returns:
- A copy of the container.
-
getTankCapacity
long getTankCapacity(int tankSlot) - Parameters:
tankSlot- The slot to get the capacity of.- Returns:
- The capacity of the given slot.
-
fromContainer
Sets the container to the same values as the given container.- Parameters:
container- The container to copy the fluids from.
-
extractFromSlot
Extracts a fluid from oneFluidHolderinto another.- Parameters:
fluidHolder- TheFluidHolderto extract from.toInsert- TheFluidHolderto insert into. With amount clamped between 0-fluid.getFluidAmount().snapshot- A runnable that will be called before the extraction happens.- Returns:
- The amount of fluid that was extracted.
-
allowsInsertion
boolean allowsInsertion()- Returns:
- Whether can be inserted into.
-
allowsExtraction
boolean allowsExtraction()- Returns:
- Whether can be extracted from.
-
isFluidValid
- Parameters:
fluidHolder- TheFluidHolderto check if can be inserted into.- Returns:
- Whether the given
FluidHoldercan be inserted into.
-
createSnapshot
FluidSnapshot createSnapshot()- Returns:
- A
FluidSnapshotof the given state of theFluidContainer.
-
readSnapshot
Sets theFluidContainerwith the given state ofFluidSnapshot.- Parameters:
snapshot- TheFluidSnapshotto set theFluidContainerto.
-
getFirstFluid
-