public class FluidUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static FluidStack |
getFluidContained(ItemStack container)
Helper method to get the fluid contained in an itemStack
|
static IFluidHandler |
getFluidHandler(ItemStack itemStack)
Helper method to get an IFluidHandler for an itemStack.
|
static IFluidHandler |
getFluidHandler(World world,
BlockPos blockPos,
EnumFacing side)
Helper method to get an IFluidHandler for at a block position.
|
static boolean |
interactWithFluidHandler(ItemStack stack,
IFluidHandler fluidHandler,
EntityPlayer player)
Used to handle the common case of a fluid item right-clicking on a fluid handler.
|
static boolean |
interactWithTank(ItemStack stack,
EntityPlayer player,
IFluidHandler tank,
EnumFacing side)
Deprecated.
|
static ItemStack |
tryEmptyBucket(ItemStack bucket,
IFluidHandler tank,
EnumFacing side)
|
static ItemStack |
tryEmptyBucket(ItemStack bucket,
IFluidHandler tank,
EnumFacing side,
EntityPlayer player)
|
static ItemStack |
tryEmptyContainer(ItemStack container,
IFluidHandler fluidDestination,
int maxAmount,
EntityPlayer player,
boolean doDrain)
Takes a filled container and tries to empty it into the given tank.
|
static boolean |
tryEmptyContainerAndStow(ItemStack container,
IFluidHandler fluidDestination,
IItemHandler inventory,
int maxAmount,
EntityPlayer player)
Takes an Fluid Container Item, tries to empty it into the fluid handler, and stows it in the given inventory.
|
static boolean |
tryEmptyFluidContainerItem(ItemStack container,
IFluidHandler tank,
EnumFacing side,
EntityPlayer player)
|
static boolean |
tryEmptyFluidContainerItem(ItemStack container,
IFluidHandler tank,
EnumFacing side,
IItemHandler inventory,
int max,
EntityPlayer player)
|
static ItemStack |
tryFillBucket(ItemStack bucket,
IFluidHandler tank,
EnumFacing side)
|
static ItemStack |
tryFillBucket(ItemStack bucket,
IFluidHandler tank,
EnumFacing side,
EntityPlayer player)
|
static ItemStack |
tryFillContainer(ItemStack container,
IFluidHandler fluidSource,
int maxAmount,
EntityPlayer player,
boolean doFill)
Fill a container from the given fluidSource.
|
static boolean |
tryFillContainerAndStow(ItemStack container,
IFluidHandler fluidSource,
IItemHandler inventory,
int maxAmount,
EntityPlayer player)
Takes an Fluid Container Item and tries to fill it from the given tank.
|
static boolean |
tryFillFluidContainerItem(ItemStack container,
IFluidHandler tank,
EnumFacing side,
EntityPlayer player)
|
static boolean |
tryFillFluidContainerItem(ItemStack container,
IFluidHandler tank,
EnumFacing side,
IItemHandler inventory,
int max,
EntityPlayer player)
|
static FluidStack |
tryFluidTransfer(IFluidHandler fluidDestination,
IFluidHandler fluidSource,
int maxAmount,
boolean doTransfer)
Fill a destination fluid handler from a source fluid handler.
|
static ItemStack |
tryPickUpFluid(ItemStack emptyContainer,
EntityPlayer playerIn,
World worldIn,
BlockPos pos,
EnumFacing side)
Attempts to pick up a fluid in the world and put it in an empty container item.
|
static boolean |
tryPlaceFluid(EntityPlayer player,
World worldIn,
FluidStack fluidStack,
BlockPos pos)
Tries to place a fluid in the world in block form.
|
public static boolean interactWithFluidHandler(ItemStack stack, IFluidHandler fluidHandler, EntityPlayer player)
public static ItemStack tryFillContainer(ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable EntityPlayer player, boolean doFill)
container
- The container to be filled. Will not be modified.fluidSource
- The fluid handler to be drained.maxAmount
- The largest amount of fluid that should be transferred.player
- The player to make the filling noise. Pass null for no noise.doFill
- true if the container should actually be filled, false if it should be simulated.@Nullable public static ItemStack tryEmptyContainer(ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain)
container
- The filled container. Will not be modified.fluidDestination
- The fluid handler to be filled by the container.maxAmount
- The largest amount of fluid that should be transferred.player
- Player for making the bucket drained sound. Pass null for no noise.doDrain
- true if the container should actually be drained, false if it should be simulated.public static boolean tryFillContainerAndStow(ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
container
- The Fluid Container Itemstack to fill. This stack WILL be modified on success.fluidSource
- The fluid source to fill frominventory
- An inventory where any additionally created item (filled container if multiple empty are present) are putmaxAmount
- Maximum amount of fluid to take from the tank.player
- The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack.public static boolean tryEmptyContainerAndStow(ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
container
- The filled Fluid Container Itemstack to empty. This stack WILL be modified on success.fluidDestination
- The fluid destination to fill from the fluid container.inventory
- An inventory where any additionally created item (filled container if multiple empty are present) are putmaxAmount
- Maximum amount of fluid to take from the tank.player
- The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack.@Nullable public static FluidStack tryFluidTransfer(IFluidHandler fluidDestination, IFluidHandler fluidSource, int maxAmount, boolean doTransfer)
fluidDestination
- The fluid handler to be filled.fluidSource
- The fluid handler to be drained.maxAmount
- The largest amount of fluid that should be transferred.doTransfer
- True if the transfer should actually be done, false if it should be simulated.@Nullable public static IFluidHandler getFluidHandler(ItemStack itemStack)
@Nullable public static FluidStack getFluidContained(ItemStack container)
@Nullable public static IFluidHandler getFluidHandler(World world, BlockPos blockPos, @Nullable EnumFacing side)
public static boolean tryPlaceFluid(@Nullable EntityPlayer player, World worldIn, FluidStack fluidStack, BlockPos pos)
ItemBucket.tryPlaceContainedLiquid(EntityPlayer, World, BlockPos)
player
- Player who places the fluid. May be null for blocks like dispensers.worldIn
- World to place the fluid influidStack
- The fluidStack to place.pos
- The position in the world to place the fluid block@Nullable public static ItemStack tryPickUpFluid(ItemStack emptyContainer, @Nullable EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side)
emptyContainer
- The empty container to fill. Will not be modified.playerIn
- The player filling the container. Optional.worldIn
- The world the fluid is in.pos
- The position of the fluid in the world.side
- The side of the fluid that is being drained.@Deprecated public static boolean interactWithTank(ItemStack stack, EntityPlayer player, IFluidHandler tank, EnumFacing side)
interactWithFluidHandler(ItemStack, IFluidHandler, EntityPlayer)
@Deprecated public static ItemStack tryFillBucket(ItemStack bucket, IFluidHandler tank, EnumFacing side)
@Deprecated public static ItemStack tryFillBucket(ItemStack bucket, IFluidHandler tank, EnumFacing side, EntityPlayer player)
bucket
- The empty bucket. Will not be modified.tank
- The tank to fill the bucket fromside
- Side to access the tank from@Deprecated public static ItemStack tryEmptyBucket(ItemStack bucket, IFluidHandler tank, EnumFacing side)
@Deprecated public static ItemStack tryEmptyBucket(ItemStack bucket, IFluidHandler tank, EnumFacing side, EntityPlayer player)
bucket
- The filled buckettank
- The tank to fill with the bucketside
- Side to access the tank fromplayer
- Player for making the bucket drained sound.@Deprecated public static boolean tryFillFluidContainerItem(ItemStack container, IFluidHandler tank, EnumFacing side, EntityPlayer player)
container
- The IFluidContainerItem Itemstack to fill. WILL BE MODIFIED!tank
- The tank to fill fromside
- Side to access the tank fromplayer
- The player that tries to fill the bucket. Needed if the input itemstack has a stacksize > 1 to determine where the filled container goes.@Deprecated public static boolean tryEmptyFluidContainerItem(ItemStack container, IFluidHandler tank, EnumFacing side, EntityPlayer player)
@Deprecated public static boolean tryFillFluidContainerItem(ItemStack container, IFluidHandler tank, EnumFacing side, IItemHandler inventory, int max, @Nullable EntityPlayer player)
container
- The IFluidContainerItem Itemstack to fill. WILL BE MODIFIED!tank
- The tank to fill fromside
- Side to access the tank frominventory
- An inventory where any additionally created item (filled container if multiple empty are present) are putmax
- Maximum amount to take from the tank. Uses IFluidContainerItem capacity if <= 0player
- The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack.@Deprecated public static boolean tryEmptyFluidContainerItem(ItemStack container, IFluidHandler tank, EnumFacing side, IItemHandler inventory, int max, EntityPlayer player)
container
- The IFluidContainerItem Itemstack to empty. WILL BE MODIFIED!tank
- The tank to fillside
- Side to access the tank frominventory
- An inventory where any additionally created item (filled container if multiple empty are present) are putmax
- Maximum amount to take from the tank. Uses IFluidContainerItem capacity if <= 0player
- The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the emptied stack.