Class FluidStorageUtil

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

public final class FluidStorageUtil extends Object
Helper functions to work with fluid storages.
  • 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 original container item is not modified, and the player's inventory will additionally receive a copy of the modified container, if it doesn't have it yet.

      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.