Interface IFluidHandler
- All Known Subinterfaces:
IFluidHandlerItem
- All Known Implementing Classes:
BlockWrapper,BlockWrapper.LiquidContainerBlockWrapper,BucketPickupHandlerWrapper,EmptyFluidHandler,FluidBucketWrapper,FluidHandlerItemStack,FluidHandlerItemStack.Consumable,FluidHandlerItemStack.SwapEmpty,FluidHandlerItemStackSimple,FluidHandlerItemStackSimple.Consumable,FluidHandlerItemStackSimple.SwapEmpty,FluidResourceHandlerAdapter,FluidResourceHandlerItemAdapter,FluidTank,VoidFluidHandler
Deprecated, for removal: This API element is subject to removal in a future version.
Implement this interface as a capability which should handle fluids, generally storing them in
one or more internal
IFluidTank objects.
A reference implementation is provided
.invalid reference
TileFluidHandler
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptiondrain(int maxDrain, IFluidHandler.FluidAction action) Deprecated, for removal: This API element is subject to removal in a future version.drain(FluidStack resource, IFluidHandler.FluidAction action) Deprecated, for removal: This API element is subject to removal in a future version.intfill(FluidStack resource, IFluidHandler.FluidAction action) Deprecated, for removal: This API element is subject to removal in a future version.getFluidInTank(int tank) Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.getAmountAsInt(int)andResourceHandler.getResource(int)instead.intgetTankCapacity(int tank) Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.getCapacityAsInt(int, T)instead, passingFluidResource.EMPTYas the resource to retrieve a general tank limit.intgetTanks()Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.size()instead.booleanisFluidValid(int tank, FluidStack stack) Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.isValid(int, T)instead, however note that it doesn't make the same strong guarantees regarding how long a resource is valid.static IFluidHandlerof(ResourceHandler<FluidResource> handler) Deprecated, for removal: This API element is subject to removal in a future version.Creates a wrapper around aResourceHandler, to present it as a legacyIFluidHandler.
-
Method Details
-
of
Deprecated, for removal: This API element is subject to removal in a future version.Creates a wrapper around aResourceHandler, to present it as a legacyIFluidHandler.This class is intended to make migration easier for code that expects an
IFluidHandler. -
getTanks
Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.size()instead.Returns the number of fluid storage units ("tanks") available- Returns:
- The number of tanks available
-
getFluidInTank
Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.getAmountAsInt(int)andResourceHandler.getResource(int)instead. Alternatively use theFluidUtil.getStack(net.neoforged.neoforge.transfer.ResourceHandler<net.neoforged.neoforge.transfer.fluid.FluidResource>, int)helper.Returns the FluidStack in a given tank.IMPORTANT: This FluidStack MUST NOT be modified. This method is not for altering internal contents. Any implementers who are able to detect modification via this method should throw an exception. It is ENTIRELY reasonable and likely that the stack returned here will be a copy.
SERIOUSLY: DO NOT MODIFY THE RETURNED FLUIDSTACK
- Parameters:
tank- Tank to query.- Returns:
- FluidStack in a given tank. FluidStack.EMPTY if the tank is empty.
-
getTankCapacity
Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.getCapacityAsInt(int, T)instead, passingFluidResource.EMPTYas the resource to retrieve a general tank limit.Retrieves the maximum fluid amount for a given tank.- Parameters:
tank- Tank to query.- Returns:
- The maximum fluid amount held by the tank.
-
isFluidValid
Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.isValid(int, T)instead, however note that it doesn't make the same strong guarantees regarding how long a resource is valid. In other words: the result ofisValidmight change.This function is a way to determine which fluids can exist inside a given handler. General purpose tanks will basically always return TRUE for this.- Parameters:
tank- Tank to query for validitystack- Stack to test with for validity- Returns:
- TRUE if the tank can hold the FluidStack, not considering current state. (Basically, is a given fluid EVER allowed in this tank?) Return FALSE if the answer to that question is 'no.'
-
fill
@Deprecated(since="1.21.9", forRemoval=true) int fill(FluidStack resource, IFluidHandler.FluidAction action) Deprecated, for removal: This API element is subject to removal in a future version.Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.- Parameters:
resource- FluidStack representing the Fluid and maximum amount of fluid to be filled.action- If SIMULATE, fill will only be simulated.- Returns:
- Amount of resource that was (or would have been, if simulated) filled.
-
drain
@Deprecated(since="1.21.9", forRemoval=true) FluidStack drain(FluidStack resource, IFluidHandler.FluidAction action) Deprecated, for removal: This API element is subject to removal in a future version.Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.- Parameters:
resource- FluidStack representing the Fluid and maximum amount of fluid to be drained.action- If SIMULATE, drain will only be simulated.- Returns:
- FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained.
-
drain
@Deprecated(since="1.21.9", forRemoval=true) FluidStack drain(int maxDrain, IFluidHandler.FluidAction action) Deprecated, for removal: This API element is subject to removal in a future version.Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.This method is not Fluid-sensitive.
- Parameters:
maxDrain- Maximum amount of fluid to drain.action- If SIMULATE, drain will only be simulated.- Returns:
- FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained.
-
ResourceHandlerwith aFluidResourceinstead. Code that is written againstIFluidHandlerbut receives aResourceHandler<FluidResource>can temporarily useof(net.neoforged.neoforge.transfer.ResourceHandler<net.neoforged.neoforge.transfer.fluid.FluidResource>)to ease migration.