Class SimpleFluidContainer
java.lang.Object
earth.terrarium.botarium.common.fluid.impl.SimpleFluidContainer
- All Implemented Interfaces:
FluidContainer,Serializable,net.minecraft.world.Clearable
- Direct Known Subclasses:
ExtractOnlyFluidContainer,InsertOnlyFluidContainer
A simple implementation for fluid storage.
This class should be wrapped by a
WrappedBlockFluidContainer or a WrappedItemFluidContainer to provide the necessary functionality.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringfinal BiPredicate<Integer,FluidHolder> final IntToLongFunctionnet.minecraft.core.NonNullList<FluidHolder> -
Constructor Summary
ConstructorsConstructorDescriptionSimpleFluidContainer(long maxAmount, int tanks, BiPredicate<Integer, FluidHolder> fluidFilter) SimpleFluidContainer(IntToLongFunction maxAmount, int tanks, BiPredicate<Integer, FluidHolder> fluidFilter) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidcopy()voiddeserialize(net.minecraft.nbt.CompoundTag root) Deserializes the information of an object from aCompoundTag.extractFluid(FluidHolder fluid, boolean simulate) Extracts aFluidHolderfrom the container.longextractFromSlot(FluidHolder fluidHolder, FluidHolder toInsert, Runnable snapshot) Extracts a fluid from oneFluidHolderinto another.voidfromContainer(FluidContainer container) Sets the container to the same values as the given container.intgetSize()longgetTankCapacity(int slot) longinsertFluid(FluidHolder fluid, boolean simulate) Inserts aFluidHolderinto the container.internalExtract(FluidHolder fluid, boolean simulate) An internal version ofFluidContainer.extractFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.longinternalInsert(FluidHolder fluid, boolean simulate) An internal version ofFluidContainer.insertFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.booleanisEmpty()booleanisFluidValid(int slot, FluidHolder fluidHolder) net.minecraft.nbt.CompoundTagserialize(net.minecraft.nbt.CompoundTag root) Serializes the information of an object to aCompoundTag.voidsetFluid(int slot, FluidHolder fluid) Sets a givenFluidHolderto a slot in the container.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface earth.terrarium.botarium.common.fluid.base.FluidContainer
getFirstFluid, readSnapshot
-
Field Details
-
FLUID_KEY
- See Also:
-
storedFluid
-
maxAmount
-
fluidFilter
-
-
Constructor Details
-
SimpleFluidContainer
public SimpleFluidContainer(IntToLongFunction maxAmount, int tanks, BiPredicate<Integer, FluidHolder> fluidFilter) -
SimpleFluidContainer
public SimpleFluidContainer(long maxAmount, int tanks, BiPredicate<Integer, FluidHolder> fluidFilter)
-
-
Method Details
-
insertFluid
Description copied from interface:FluidContainerInserts aFluidHolderinto the container.- Specified by:
insertFluidin interfaceFluidContainer- Parameters:
fluid- TheFluidHolderto be inserted into the container.simulate- If true, the container will not be modified.- Returns:
- The amount of fluid that was added to the container.
-
extractFluid
Description copied from interface:FluidContainerExtracts aFluidHolderfrom the container.- Specified by:
extractFluidin interfaceFluidContainer- Parameters:
fluid- TheFluidHolderto be extracted from the container.simulate- If true, the container will not be modified.- Returns:
- The
FluidHolderthat was extracted from the container.
-
internalInsert
Description copied from interface:FluidContainerAn internal version ofFluidContainer.insertFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.You should not call this method for other mod's containers, instead use
FluidContainer.insertFluid(FluidHolder, boolean).- Specified by:
internalInsertin interfaceFluidContainer
-
internalExtract
Description copied from interface:FluidContainerAn internal version ofFluidContainer.extractFluid(FluidHolder, boolean)that is used by mod authors looking to directly interact with their own containers.You should not call this method for other mod's containers, instead use
FluidContainer.extractFluid(FluidHolder, boolean).- Specified by:
internalExtractin interfaceFluidContainer
-
extractFromSlot
Description copied from interface:FluidContainerExtracts a fluid from oneFluidHolderinto another.- Specified by:
extractFromSlotin interfaceFluidContainer- Parameters:
fluidHolder- TheFluidHolderto extract from.toInsert- TheFluidHolderto insert into. With amount clamped between 0-fluid.getFluidAmount().snapshot- A runnable that will be called before the extraction happens.- Returns:
- The amount of fluid that was extracted.
-
setFluid
Description copied from interface:FluidContainerSets a givenFluidHolderto a slot in the container.- Specified by:
setFluidin interfaceFluidContainer- Parameters:
slot- The slot to set the fluid in.fluid- TheFluidHolderto set in the slot.
-
getFluids
- Specified by:
getFluidsin interfaceFluidContainer- Returns:
- A
ListofFluidHolderin the container.
-
getSize
public int getSize()- Specified by:
getSizein interfaceFluidContainer- Returns:
- The amount of slots in the container.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceFluidContainer- Returns:
- Whether or not the container is empty.
-
copy
- Specified by:
copyin interfaceFluidContainer- Returns:
- A copy of the container.
-
getTankCapacity
public long getTankCapacity(int slot) - Specified by:
getTankCapacityin interfaceFluidContainer- Parameters:
slot- The slot to get the capacity of.- Returns:
- The capacity of the given slot.
-
fromContainer
Description copied from interface:FluidContainerSets the container to the same values as the given container.- Specified by:
fromContainerin interfaceFluidContainer- Parameters:
container- The container to copy the fluids from.
-
deserialize
public void deserialize(net.minecraft.nbt.CompoundTag root) Description copied from interface:SerializableDeserializes the information of an object from aCompoundTag.- Specified by:
deserializein interfaceSerializable- Parameters:
root- TheCompoundTagto deserialize from.
-
serialize
public net.minecraft.nbt.CompoundTag serialize(net.minecraft.nbt.CompoundTag root) Description copied from interface:SerializableSerializes the information of an object to aCompoundTag.- Specified by:
serializein interfaceSerializable- Parameters:
root- TheCompoundTagto serialize to.- Returns:
- The
CompoundTagthat was passed in but with the information of the object serialized added to it.
-
allowsInsertion
public boolean allowsInsertion()- Specified by:
allowsInsertionin interfaceFluidContainer- Returns:
- Whether can be inserted into.
-
allowsExtraction
public boolean allowsExtraction()- Specified by:
allowsExtractionin interfaceFluidContainer- Returns:
- Whether can be extracted from.
-
isFluidValid
- Specified by:
isFluidValidin interfaceFluidContainerfluidHolder- TheFluidHolderto check if can be inserted into.- Returns:
- Whether the given
FluidHoldercan be inserted into.
-
createSnapshot
- Specified by:
createSnapshotin interfaceFluidContainer- Returns:
- A
FluidSnapshotof the given state of theFluidContainer.
-
clearContent
public void clearContent()- Specified by:
clearContentin interfacenet.minecraft.world.Clearable
-