Class FluidBucketWrapper
- java.lang.Object
-
- net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper
-
- All Implemented Interfaces:
ICapabilityProvider
,IFluidHandler
,IFluidHandlerItem
public class FluidBucketWrapper extends java.lang.Object implements IFluidHandlerItem, ICapabilityProvider
Wrapper for vanilla and forge buckets. Swaps between empty bucket and filled bucket of the correct type.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.minecraftforge.fluids.capability.IFluidHandler
IFluidHandler.FluidAction
-
-
Field Summary
Fields Modifier and Type Field Description protected ItemStack
container
private LazyOptional<IFluidHandlerItem>
holder
-
Constructor Summary
Constructors Constructor Description FluidBucketWrapper(ItemStack container)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canFillFluidType(FluidStack fluid)
FluidStack
drain(int maxDrain, IFluidHandler.FluidAction action)
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.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 action)
Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.<T> LazyOptional<T>
getCapability(Capability<T> capability, Direction facing)
Retrieves the Optional handler for the capability requested on the specific side.ItemStack
getContainer()
Get the container currently acted on by this fluid handler.FluidStack
getFluid()
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, FluidStack stack)
This function is a way to determine which fluids can exist inside a given handler.protected void
setFluid(FluidStack fluidStack)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
-
-
-
-
Field Detail
-
holder
private final LazyOptional<IFluidHandlerItem> holder
-
container
@Nonnull protected ItemStack container
-
-
Constructor Detail
-
FluidBucketWrapper
public FluidBucketWrapper(@Nonnull ItemStack container)
-
-
Method Detail
-
getContainer
@Nonnull public ItemStack getContainer()
Description copied from interface: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.- Specified by:
getContainer
in interfaceIFluidHandlerItem
-
canFillFluidType
public boolean canFillFluidType(FluidStack fluid)
-
getFluid
@Nonnull public FluidStack getFluid()
-
setFluid
protected void setFluid(@Nonnull FluidStack fluidStack)
-
getTanks
public int getTanks()
Description copied from interface:IFluidHandler
Returns the number of fluid storage units ("tanks") available- Specified by:
getTanks
in interfaceIFluidHandler
- Returns:
- The number of tanks available
-
getFluidInTank
@Nonnull public FluidStack getFluidInTank(int tank)
Description copied from interface: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
- Specified by:
getFluidInTank
in 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)
Description copied from interface:IFluidHandler
Retrieves the maximum fluid amount for a given tank.- Specified by:
getTankCapacity
in interfaceIFluidHandler
- Parameters:
tank
- Tank to query.- Returns:
- The maximum fluid amount held by the tank.
-
isFluidValid
public boolean isFluidValid(int tank, @Nonnull FluidStack stack)
Description copied from interface: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.- Specified by:
isFluidValid
in 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
public int fill(FluidStack resource, IFluidHandler.FluidAction action)
Description copied from interface:IFluidHandler
Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.- Specified by:
fill
in 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
@Nonnull public FluidStack drain(FluidStack resource, IFluidHandler.FluidAction action)
Description copied from interface:IFluidHandler
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.- Specified by:
drain
in 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
@Nonnull public FluidStack drain(int maxDrain, IFluidHandler.FluidAction action)
Description copied from interface:IFluidHandler
Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler. This method is not Fluid-sensitive.- Specified by:
drain
in 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.
-
getCapability
@Nonnull public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
Description copied from interface: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.- Specified by:
getCapability
in interfaceICapabilityProvider
- Returns:
- The requested an optional holding the requested capability.
-
-