Class FluidStorage

java.lang.Object
net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage

@Experimental public final class FluidStorage extends Object
Access to Storage<FluidVariant> instances.

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.

  • Field Details

  • Method Details

    • combinedItemApiProvider

      public static Event<FluidStorage.CombinedItemApiProvider> combinedItemApiProvider(net.minecraft.item.Item item)
      Get or create and register a FluidStorage.CombinedItemApiProvider event for the passed item. Allows multiple API providers to provide a Storage<FluidVariant> implementation for the same item.

      When the item is queried for an API through ITEM, all the providers registered through the event will be invoked. All non-null Storage<FluidVariant> instances returned by the providers will be combined in a single storage, that will be the final result of the query, or null if no storage is offered by the event handlers.

      This is appropriate to use when multiple mods could wish to expose the Fluid API for some items, for example when dealing with items added by the base Minecraft game such as buckets or empty bottles. A typical usage example is a mod adding support for filling empty bottles with a honey fluid: Fabric API already registers a storage for empty bottles to allow filling them with water through the event, and a mod can register an event handler that will attach a second storage allowing empty bottles to be filled with its honey fluid.

      Throws:
      IllegalStateException - If an incompatible provider is already registered for the item.