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

public interface FluidContainer extends Serializable, net.minecraft.world.Clearable
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    boolean
     
     
     
    extractFluid(FluidHolder fluid, boolean simulate)
    Extracts a FluidHolder from the container.
    long
    extractFromSlot(FluidHolder fluidHolder, FluidHolder toInsert, Runnable snapshot)
    Extracts a fluid from one FluidHolder into another.
    void
    Sets the container to the same values as the given container.
    default FluidHolder
     
     
    int
     
    long
    getTankCapacity(int tankSlot)
     
    static boolean
    holdsFluid(net.minecraft.world.item.ItemStack stack)
    Checks if the given item stack holds fluid.
    static boolean
    holdsFluid(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable net.minecraft.core.Direction direction)
    Checks if the given block entity holds fluid.
    static boolean
    holdsFluid(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 boolean
    holdsFluid(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.
    long
    insertFluid(FluidHolder fluid, boolean simulate)
    Inserts a FluidHolder into the container.
    default FluidHolder
    internalExtract(FluidHolder fluid, boolean simulate)
    An internal version of extractFluid(FluidHolder, boolean) that is used by mod authors looking to directly interact with their own containers.
    default long
    internalInsert(FluidHolder fluids, boolean simulate)
    An internal version of insertFluid(FluidHolder, boolean) that is used by mod authors looking to directly interact with their own containers.
    boolean
     
    default boolean
    isFluidValid(int slot, FluidHolder fluidHolder)
     
    static @Nullable ItemFluidContainer
    Retrieves an instance of FluidContainer for the given item stack.
    static @Nullable FluidContainer
    of(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 FluidContainer
    of(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 FluidContainer
    of(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 void
    Sets the FluidContainer with the given state of FluidSnapshot.
    void
    setFluid(int slot, FluidHolder fluid)
    Sets a given FluidHolder to a slot in the container.

    Methods inherited from interface net.minecraft.world.Clearable

    clearContent

    Methods 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

      @Nullable @ImplementedByExtension static @Nullable ItemFluidContainer of(ItemStackHolder holder)
      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

      long insertFluid(FluidHolder fluid, boolean simulate)
      Inserts a FluidHolder into the container.
      Parameters:
      fluid - The FluidHolder to 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

      default long internalInsert(FluidHolder fluids, boolean simulate)
      An internal version of insertFluid(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

      FluidHolder extractFluid(FluidHolder fluid, boolean simulate)
      Extracts a FluidHolder from the container.
      Parameters:
      fluid - The FluidHolder to be extracted from the container.
      simulate - If true, the container will not be modified.
      Returns:
      The FluidHolder that was extracted from the container.
    • internalExtract

      default FluidHolder internalExtract(FluidHolder fluid, boolean simulate)
      An internal version of extractFluid(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

      void setFluid(int slot, FluidHolder fluid)
      Sets a given FluidHolder to a slot in the container.
      Parameters:
      slot - The slot to set the fluid in.
      fluid - The FluidHolder to set in the slot.
    • getFluids

      List<FluidHolder> getFluids()
      Returns:
      A List of FluidHolder in 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

      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

      void fromContainer(FluidContainer container)
      Sets the container to the same values as the given container.
      Parameters:
      container - The container to copy the fluids from.
    • extractFromSlot

      long extractFromSlot(FluidHolder fluidHolder, FluidHolder toInsert, Runnable snapshot)
      Extracts a fluid from one FluidHolder into another.
      Parameters:
      fluidHolder - The FluidHolder to extract from.
      toInsert - The FluidHolder to 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

      default boolean isFluidValid(int slot, FluidHolder fluidHolder)
      Parameters:
      fluidHolder - The FluidHolder to check if can be inserted into.
      Returns:
      Whether the given FluidHolder can be inserted into.
    • createSnapshot

      FluidSnapshot createSnapshot()
      Returns:
      A FluidSnapshot of the given state of the FluidContainer.
    • readSnapshot

      default void readSnapshot(FluidSnapshot snapshot)
      Sets the FluidContainer with the given state of FluidSnapshot.
      Parameters:
      snapshot - The FluidSnapshot to set the FluidContainer to.
    • getFirstFluid

      default FluidHolder getFirstFluid()