Class FluidHelpers

java.lang.Object
org.cyclops.cyclopscore.helper.FluidHelpers

public final class FluidHelpers extends Object
Contains helper methods for various fluid specific things.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canCompletelyFill(net.neoforged.neoforge.fluids.capability.IFluidHandler source, net.neoforged.neoforge.fluids.capability.IFluidHandler destination)
    If this destination can completely contain the given fluid in the given source.
    static net.neoforged.neoforge.fluids.FluidStack
    copy(net.neoforged.neoforge.fluids.FluidStack fluidStack)
    Copy the given fluid stack
    static net.neoforged.neoforge.fluids.FluidStack
    extractFromInventory(int amount, net.minecraft.world.item.ItemStack blacklistedStack, net.minecraft.world.level.material.Fluid fluidWhitelist, net.minecraft.world.entity.player.Player player, net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction action)
    Extract the given fluid amount from any item inside the player's inventory.
    static net.neoforged.neoforge.fluids.FluidStack
    extractFromItemOrInventory(int amount, net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.entity.player.Player player, net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction action)
    Extract the given fluid amount from the given item, or from the player's inventory if that fails.
    static int
    getAmount(net.neoforged.neoforge.fluids.FluidStack fluidStack)
    Get the fluid amount of the given stack in a safe manner.
    static int
    getCapacity(net.neoforged.neoforge.fluids.capability.IFluidHandler fluidHandler)
    Get the capacity of a fluid handler.
    static net.neoforged.neoforge.fluids.FluidStack
    getFluid(net.neoforged.neoforge.fluids.capability.IFluidHandler fluidHandler)
    Get the fluid contained in a fluid handler.
    getFluidHandlerItemCapacity(net.minecraft.world.item.ItemStack itemStack)
     
    static boolean
    hasFluid(net.neoforged.neoforge.fluids.capability.IFluidHandler fluidHandler)
    Check if the fluid handler is not empty.
    static void
    placeOrPickUpFluid(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, net.minecraft.core.Direction side)
    Try placing or picking up fluids from the held item.
    static net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction
    simulateBooleanToAction(boolean simulate)
    Convert a boolean-based simulate to a fluid action enum value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • FluidHelpers

      public FluidHelpers()
  • Method Details

    • getAmount

      public static int getAmount(net.neoforged.neoforge.fluids.FluidStack fluidStack)
      Get the fluid amount of the given stack in a safe manner.
      Parameters:
      fluidStack - The fluid stack
      Returns:
      The fluid amount.
    • copy

      public static net.neoforged.neoforge.fluids.FluidStack copy(net.neoforged.neoforge.fluids.FluidStack fluidStack)
      Copy the given fluid stack
      Parameters:
      fluidStack - The fluid stack to copy.
      Returns:
      A copy of the fluid stack.
    • canCompletelyFill

      public static boolean canCompletelyFill(net.neoforged.neoforge.fluids.capability.IFluidHandler source, net.neoforged.neoforge.fluids.capability.IFluidHandler destination)
      If this destination can completely contain the given fluid in the given source.
      Parameters:
      source - The source of the fluid that has to be moved.
      destination - The target of the fluid that has to be moved.
      Returns:
      If the destination can completely contain the fluid of the source.
    • getFluid

      public static net.neoforged.neoforge.fluids.FluidStack getFluid(@Nullable net.neoforged.neoforge.fluids.capability.IFluidHandler fluidHandler)
      Get the fluid contained in a fluid handler.
      Parameters:
      fluidHandler - The fluid handler.
      Returns:
      The fluid.
    • hasFluid

      public static boolean hasFluid(@Nullable net.neoforged.neoforge.fluids.capability.IFluidHandler fluidHandler)
      Check if the fluid handler is not empty.
      Parameters:
      fluidHandler - The fluid handler.
      Returns:
      If it is not empty.
    • getCapacity

      public static int getCapacity(@Nullable net.neoforged.neoforge.fluids.capability.IFluidHandler fluidHandler)
      Get the capacity of a fluid handler.
      Parameters:
      fluidHandler - The fluid handler.
      Returns:
      The capacity.
    • getFluidHandlerItemCapacity

      public static Optional<IFluidHandlerItemCapacity> getFluidHandlerItemCapacity(net.minecraft.world.item.ItemStack itemStack)
      Parameters:
      itemStack - The itemstack
      Returns:
      The item capacity fluid handler.
    • extractFromInventory

      public static net.neoforged.neoforge.fluids.FluidStack extractFromInventory(int amount, @Nullable net.minecraft.world.item.ItemStack blacklistedStack, @Nullable net.minecraft.world.level.material.Fluid fluidWhitelist, net.minecraft.world.entity.player.Player player, net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction action)
      Extract the given fluid amount from any item inside the player's inventory.
      Parameters:
      amount - A fluid amount to extract.
      blacklistedStack - The itemstack to skip. Useful if this is the stack that you are inserting to.
      fluidWhitelist - A fluid to transfer, can be null to allow any fluid to be transferred.
      player - The player to scan the inventory from.
      action - The fluid action.
      Returns:
      The extracted fluidstack.
    • extractFromItemOrInventory

      public static net.neoforged.neoforge.fluids.FluidStack extractFromItemOrInventory(int amount, net.minecraft.world.item.ItemStack itemStack, @Nullable net.minecraft.world.entity.player.Player player, net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction action)
      Extract the given fluid amount from the given item, or from the player's inventory if that fails.
      Parameters:
      amount - A fluid amount to extract.
      itemStack - The item to extract from first.
      player - The player to scan the inventory from.
      action - The fluid action.
      Returns:
      The extracted fluidstack.
    • placeOrPickUpFluid

      public static void placeOrPickUpFluid(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, net.minecraft.core.Direction side)
      Try placing or picking up fluids from the held item. This can be called in Item.use(net.minecraft.world.level.Level, net.minecraft.world.entity.player.Player, net.minecraft.world.InteractionHand).
      Parameters:
      player - The active player.
      hand - The active hand.
      world - The world.
      blockPos - The target position.
      side - The target side.
    • simulateBooleanToAction

      public static net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction simulateBooleanToAction(boolean simulate)
      Convert a boolean-based simulate to a fluid action enum value.
      Parameters:
      simulate - If in simulation mode.
      Returns:
      The fluid action.