Class FluidHandlerItemStackSimple
java.lang.Object
net.neoforged.neoforge.fluids.capability.templates.FluidHandlerItemStackSimple
- All Implemented Interfaces:
IFluidHandler,IFluidHandlerItem
- Direct Known Subclasses:
FluidHandlerItemStackSimple.Consumable,FluidHandlerItemStackSimple.SwapEmpty
@Deprecated(since="1.21.9",
forRemoval=true)
public class FluidHandlerItemStackSimple
extends Object
implements IFluidHandlerItem
Deprecated, for removal: This API element is subject to removal in a future version.
FluidHandlerItemStackSimple is a template capability provider for ItemStacks.
Data is stored in a
SimpleFluidContent component.
This implementation only allows item containers to be fully filled or emptied, similar to vanilla buckets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated, for removal: This API element is subject to removal in a future version.Deprecated with no direct equivalent, howeverItemAccessFluidHandlercan serve as inspiration.static classDeprecated, for removal: This API element is subject to removal in a future version.UseItemAccessFluidHandlerinstead, with an override ofItemAccessFluidHandler.update(net.neoforged.neoforge.transfer.item.ItemResource, int, net.neoforged.neoforge.transfer.fluid.FluidResource, int)to return a different item resource if the fluid amount is 0.Nested classes/interfaces inherited from interface net.neoforged.neoforge.fluids.capability.IFluidHandler
IFluidHandler.FluidAction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intDeprecated, for removal: This API element is subject to removal in a future version.protected final Supplier<DataComponentType<SimpleFluidContent>> Deprecated, for removal: This API element is subject to removal in a future version.protected ItemStackDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionFluidHandlerItemStackSimple(Supplier<DataComponentType<SimpleFluidContent>> componentType, ItemStack container, int capacity) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDrainFluidType(FluidStack fluid) Deprecated, for removal: This API element is subject to removal in a future version.booleancanFillFluidType(FluidStack fluid) Deprecated, for removal: This API element is subject to removal in a future version.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.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.intfill(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.Deprecated, for removal: This API element is subject to removal in a future version.Get the container currently acted on by this fluid handler.getFluid()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.Returns the FluidStack in a given tank.intgetTankCapacity(int tank) Deprecated, for removal: This API element is subject to removal in a future version.Retrieves the maximum fluid amount for a given tank.intgetTanks()Deprecated, for removal: This API element is subject to removal in a future version.Returns the number of fluid storage units ("tanks") availablebooleanisFluidValid(int tank, FluidStack stack) Deprecated, for removal: This API element is subject to removal in a future version.This function is a way to determine which fluids can exist inside a given handler.protected voidDeprecated, for removal: This API element is subject to removal in a future version.Override this method for special handling.protected voidsetFluid(FluidStack fluid) Deprecated, for removal: This API element is subject to removal in a future version.
-
Field Details
-
componentType
Deprecated, for removal: This API element is subject to removal in a future version. -
container
Deprecated, for removal: This API element is subject to removal in a future version. -
capacity
protected int capacityDeprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
FluidHandlerItemStackSimple
public FluidHandlerItemStackSimple(Supplier<DataComponentType<SimpleFluidContent>> componentType, ItemStack container, int capacity) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
componentType- The data component type to use for data storage.container- The container itemStack, data is stored on it directly as NBT.capacity- The maximum capacity of this fluid tank.
-
-
Method Details
-
getContainer
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:IFluidHandlerItemGet the container currently acted on by this fluid handler. The ItemStack may be different from its initial state, in the case of fluid containers that have different items for their filled and empty states. May be an empty item if the container was drained and is consumable.- Specified by:
getContainerin interfaceIFluidHandlerItem
-
getFluid
Deprecated, for removal: This API element is subject to removal in a future version. -
setFluid
Deprecated, for removal: This API element is subject to removal in a future version. -
getTanks
public int getTanks()Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:IFluidHandlerReturns the number of fluid storage units ("tanks") available- Specified by:
getTanksin interfaceIFluidHandler- Returns:
- The number of tanks available
-
getFluidInTank
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:IFluidHandlerReturns 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
- Specified by:
getFluidInTankin interfaceIFluidHandler- Parameters:
tank- Tank to query.- Returns:
- FluidStack in a given tank. FluidStack.EMPTY if the tank is empty.
-
getTankCapacity
public int getTankCapacity(int tank) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:IFluidHandlerRetrieves the maximum fluid amount for a given tank.- Specified by:
getTankCapacityin interfaceIFluidHandler- 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.Description copied from interface:IFluidHandlerThis function is a way to determine which fluids can exist inside a given handler. General purpose tanks will basically always return TRUE for this.- Specified by:
isFluidValidin interfaceIFluidHandler- 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, for removal: This API element is subject to removal in a future version.Description copied from interface:IFluidHandlerFills fluid into internal tanks, distribution is left entirely to the IFluidHandler.- Specified by:
fillin interfaceIFluidHandler- 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, for removal: This API element is subject to removal in a future version.Description copied from interface:IFluidHandlerDrains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.- Specified by:
drainin interfaceIFluidHandler- 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, for removal: This API element is subject to removal in a future version.Description copied from interface:IFluidHandlerDrains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.This method is not Fluid-sensitive.
- Specified by:
drainin interfaceIFluidHandler- 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.
-
canFillFluidType
Deprecated, for removal: This API element is subject to removal in a future version. -
canDrainFluidType
Deprecated, for removal: This API element is subject to removal in a future version. -
setContainerToEmpty
protected void setContainerToEmpty()Deprecated, for removal: This API element is subject to removal in a future version.Override this method for special handling. Can be used to swap out the container's item for a different one with "container.setItem". Can be used to destroy the container with "container.stackSize--"
-
ItemAccessFluidHandler, with an override ofItemAccessFluidHandler.update(net.neoforged.neoforge.transfer.item.ItemResource, int, net.neoforged.neoforge.transfer.fluid.FluidResource, int)to return an empty resource if the fluid amount is not exactly 0 or the capacity of the handler.