Package net.minecraftforge.fluids
Interface IFluidBlock
public interface IFluidBlock
Implement this interface on Block classes which represent world-placeable Fluids.
NOTE: Using/extending the reference implementations
BlockFluidBase
is encouraged.-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check to see if a block can be drained.drain
(World world, BlockPos pos, IFluidHandler.FluidAction action) Attempt to drain the block.float
getFilledPercentage
(World world, BlockPos pos) Returns the amount of a single block is filled.getFluid()
Returns the Fluid associated with this Block.int
place
(World world, BlockPos pos, FluidStack fluidStack, IFluidHandler.FluidAction action) Attempts to place the block at a given position.
-
Method Details
-
getFluid
Fluid getFluid()Returns the Fluid associated with this Block. -
place
int place(World world, BlockPos pos, @Nonnull FluidStack fluidStack, IFluidHandler.FluidAction action) Attempts to place the block at a given position. The placed block's level will correspond to the provided fluid amount. This method should be called by fluid containers such as buckets, but it is recommended to useFluidUtil
.- Parameters:
world
- the world to place the block inpos
- the position to place the block atfluidStack
- the fluid stack to get the required data fromaction
- If SIMULATE, the placement will only be simulated- Returns:
- the amount of fluid extracted from the provided stack to achieve some fluid level
-
drain
Attempt to drain the block. This method should be called by devices such as pumps. NOTE: The block is intended to handle its own state changes.- Parameters:
action
- If SIMULATE, the drain will only be simulated.- Returns:
-
canDrain
Check to see if a block can be drained. This method should be called by devices such as pumps.- Returns:
-
getFilledPercentage
Returns the amount of a single block is filled. Value between 0 and 1. 1 meaning the entire 1x1x1 cube is full, 0 meaning completely empty. If the return value is negative. It will be treated as filling the block from the top down instead of bottom up.- Returns:
-