Class FullItemFluidStorage

java.lang.Object
net.fabricmc.fabric.api.transfer.v1.fluid.base.FullItemFluidStorage
All Implemented Interfaces:
Iterable<StorageView<FluidVariant>>, ExtractionOnlyStorage<FluidVariant>, SingleSlotStorage<FluidVariant>, Storage<FluidVariant>, StorageView<FluidVariant>

@Experimental public final class FullItemFluidStorage extends Object implements ExtractionOnlyStorage<FluidVariant>, SingleSlotStorage<FluidVariant>
Base implementation of a fluid storage for a full item. The full item contains some fixed amount of a fluid variant, which can be extracted entirely to yield an empty item. The default behavior is to copy the NBT from the full item to the empty item, however there is a second constructor that allows customizing the mapping.

This is used similarly to EmptyItemFluidStorage.

Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.

  • Constructor Details

    • FullItemFluidStorage

      public FullItemFluidStorage(ContainerItemContext context, Item emptyItem, FluidVariant containedFluid, long containedAmount)
      Create a new instance.
      Parameters:
      context - The current context.
      emptyItem - The new item after a successful extract operation.
      containedFluid - The contained fluid variant.
      containedAmount - How much of containedFluid is contained.
    • FullItemFluidStorage

      public FullItemFluidStorage(ContainerItemContext context, Function<ItemVariant,ItemVariant> fullToEmptyMapping, FluidVariant containedFluid, long containedAmount)
      Create a new instance, with a custom mapping function. The mapping function allows customizing how the NBT of the empty item depends on the NBT of the full item. The default behavior with the other constructor is to just copy the full NBT.
      Parameters:
      context - The current context.
      fullToEmptyMapping - A function mapping the full item variant, to the variant that should be used for the empty item after a successful extract operation.
      containedFluid - The contained fluid variant.
      containedAmount - How much of containedFluid is contained.
  • Method Details