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 Details

    • of

      @Nullable @ImplementedByExtension static @Nullable FluidContainer of(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, 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)
    • of

      @Nullable static @Nullable FluidContainer of(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable @Nullable net.minecraft.core.Direction direction)
    • of

      @Nullable @ImplementedByExtension static @Nullable FluidContainer of(ItemStackHolder holder)
    • holdsFluid

      @ImplementedByExtension static boolean holdsFluid(net.minecraft.world.item.ItemStack stack)
    • holdsFluid

      @ImplementedByExtension static boolean holdsFluid(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, 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)
    • holdsFluid

      static boolean holdsFluid(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable @Nullable net.minecraft.core.Direction direction)
    • 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:
      Weather 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:
      Weather can be inserted into.
    • allowsExtraction

      boolean allowsExtraction()
      Returns:
      Weather can be extracted from.
    • isFluidValid

      default boolean isFluidValid(int slot, FluidHolder fluidHolder)
      Parameters:
      fluidHolder - The FluidHolder to check if can be inserted into.
      Returns:
      Weather 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.