Class FluidStorageUtil

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

@Experimental public final class FluidStorageUtil extends Object
Helper functions to work with fluid storages.

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.

  • Method Details

    • interactWithFluidStorage

      public static boolean interactWithFluidStorage(Storage<FluidVariant> storage, PlayerEntity player, Hand hand)
      Try to make the item in a player hand "interact" with a fluid storage. This can be used when a player right-clicks a tank, for example.

      More specifically, this function tries to find a fluid storing item in the player's hand. Then, it tries to fill that item from the storage. If that fails, it tries to fill the storage from that item.

      Only up to one fluid variant will be moved, and the corresponding emptying/filling sound will be played. In creative mode, the player's inventory will not be modified.

      Parameters:
      storage - The storage that the player is interacting with.
      player - The player.
      hand - The hand that the player used.
      Returns:
      True if some fluid was moved.