类 FluidHandlerItemStack
java.lang.Object
net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack
- 所有已实现的接口:
ICapabilityProvider
,IFluidHandler
,IFluidHandlerItem
FluidHandlerItemStack is a template capability provider for ItemStacks.
Data is stored directly in the vanilla NBT, in the same way as the old ItemFluidContainer.
This class allows an ItemStack to contain any partial level of fluid up to its capacity, unlike
FluidHandlerItemStackSimple
Additional examples are provided to enable consumable fluid containers (see FluidHandlerItemStack.Consumable
),
fluid containers with different empty and full items (see FluidHandlerItemStack.SwapEmpty
,-
嵌套类概要
嵌套类修饰符和类型类说明static class
Destroys the container item when it's emptied.static class
Swaps the container item for a different one when it's emptied.从接口继承的嵌套类/接口 net.minecraftforge.fluids.capability.IFluidHandler
IFluidHandler.FluidAction
-
字段概要
字段修饰符和类型字段说明protected int
protected @NotNull ItemStack
static final String
private final LazyOptional<IFluidHandlerItem>
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明boolean
canDrainFluidType
(FluidStack fluid) boolean
canFillFluidType
(FluidStack fluid) @NotNull FluidStack
drain
(int maxDrain, IFluidHandler.FluidAction action) Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.@NotNull FluidStack
drain
(FluidStack resource, IFluidHandler.FluidAction action) Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.int
fill
(FluidStack resource, IFluidHandler.FluidAction doFill) Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.<T> @NotNull LazyOptional<T>
getCapability
(@NotNull Capability<T> capability, @Nullable Direction facing) Retrieves the Optional handler for the capability requested on the specific side.@NotNull ItemStack
Get the container currently acted on by this fluid handler.@NotNull FluidStack
getFluid()
@NotNull FluidStack
getFluidInTank
(int tank) Returns the FluidStack in a given tank.int
getTankCapacity
(int tank) Retrieves the maximum fluid amount for a given tank.int
getTanks()
Returns the number of fluid storage units ("tanks") availableboolean
isFluidValid
(int tank, @NotNull FluidStack stack) This function is a way to determine which fluids can exist inside a given handler.protected void
Override this method for special handling.protected void
setFluid
(FluidStack fluid) 从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
-
字段详细资料
-
FLUID_NBT_KEY
- 另请参阅:
-
holder
-
container
-
capacity
protected int capacity
-
-
构造器详细资料
-
FluidHandlerItemStack
- 参数:
container
- The container itemStack, data is stored on it directly as NBT.capacity
- The maximum capacity of this fluid tank.
-
-
方法详细资料
-
getContainer
从接口复制的说明:IFluidHandlerItem
Get 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.- 指定者:
getContainer
在接口中IFluidHandlerItem
-
getFluid
-
setFluid
-
getTanks
public int getTanks()从接口复制的说明:IFluidHandler
Returns the number of fluid storage units ("tanks") available- 指定者:
getTanks
在接口中IFluidHandler
- 返回:
- The number of tanks available
-
getFluidInTank
从接口复制的说明:IFluidHandler
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
- 指定者:
getFluidInTank
在接口中IFluidHandler
- 参数:
tank
- Tank to query.- 返回:
- FluidStack in a given tank. FluidStack.EMPTY if the tank is empty.
-
getTankCapacity
public int getTankCapacity(int tank) 从接口复制的说明:IFluidHandler
Retrieves the maximum fluid amount for a given tank.- 指定者:
getTankCapacity
在接口中IFluidHandler
- 参数:
tank
- Tank to query.- 返回:
- The maximum fluid amount held by the tank.
-
isFluidValid
从接口复制的说明:IFluidHandler
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.- 指定者:
isFluidValid
在接口中IFluidHandler
- 参数:
tank
- Tank to query for validitystack
- Stack to test with for validity- 返回:
- 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
从接口复制的说明:IFluidHandler
Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.- 指定者:
fill
在接口中IFluidHandler
- 参数:
resource
- FluidStack representing the Fluid and maximum amount of fluid to be filled.doFill
- If SIMULATE, fill will only be simulated.- 返回:
- Amount of resource that was (or would have been, if simulated) filled.
-
drain
从接口复制的说明:IFluidHandler
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.- 指定者:
drain
在接口中IFluidHandler
- 参数:
resource
- FluidStack representing the Fluid and maximum amount of fluid to be drained.action
- If SIMULATE, drain will only be simulated.- 返回:
- FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained.
-
drain
从接口复制的说明:IFluidHandler
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.This method is not Fluid-sensitive.
- 指定者:
drain
在接口中IFluidHandler
- 参数:
maxDrain
- Maximum amount of fluid to drain.action
- If SIMULATE, drain will only be simulated.- 返回:
- FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained.
-
canFillFluidType
-
canDrainFluidType
-
setContainerToEmpty
protected void setContainerToEmpty()Override this method for special handling. Can be used to swap out or destroy the container. -
getCapability
@NotNull public <T> @NotNull LazyOptional<T> getCapability(@NotNull @NotNull Capability<T> capability, @Nullable @Nullable Direction facing) 从接口复制的说明:ICapabilityProvider
Retrieves the Optional handler for the capability requested on the specific side. The return value CAN be the same for multiple faces. Modders are encouraged to cache this value, using the listener capabilities of the Optional to be notified if the requested capability get lost.- 指定者:
getCapability
在接口中ICapabilityProvider
- 参数:
capability
- The capability to checkfacing
- The Side to check from, CAN BE NULL. Null is defined to represent 'internal' or 'self'- 返回:
- The requested an optional holding the requested capability.
-