Record Class PlatformFluidItemHandler
java.lang.Object
java.lang.Record
earth.terrarium.botarium.fabric.fluid.storage.PlatformFluidItemHandler
- All Implemented Interfaces:
FluidContainer,ItemFluidContainer,Serializable,net.minecraft.world.Clearable
public record PlatformFluidItemHandler(ItemStackHolder stack, net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext context, net.fabricmc.fabric.api.transfer.v1.storage.Storage<net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant> storage)
extends Record
implements ItemFluidContainer
-
Constructor Summary
ConstructorsConstructorDescriptionPlatformFluidItemHandler(ItemStackHolder stack, net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext context, net.fabricmc.fabric.api.transfer.v1.storage.Storage<net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant> storage) Creates an instance of aPlatformFluidItemHandlerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidnet.fabricmc.fabric.api.transfer.v1.context.ContainerItemContextcontext()Returns the value of thecontextrecord component.copy()voiddeserialize(net.minecraft.nbt.CompoundTag nbt) Deserializes the information of an object from aCompoundTag.final booleanIndicates whether some other object is "equal to" this one.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.net.minecraft.world.item.ItemStackintgetSize()longgetTankCapacity(int tank) final inthashCode()Returns a hash code value for this object.longinsertFluid(FluidHolder fluid, boolean simulate) Inserts aFluidHolderinto the container.booleanisEmpty()static @Nullable PlatformFluidItemHandlerof(ItemStackHolder stack) Retrieves an instance of FluidContainer for the given item stack.net.minecraft.nbt.CompoundTagserialize(net.minecraft.nbt.CompoundTag nbt) Serializes the information of an object to aCompoundTag.voidsetFluid(int slot, FluidHolder fluid) Sets a givenFluidHolderto a slot in the container.stack()Returns the value of thestackrecord component.net.fabricmc.fabric.api.transfer.v1.storage.Storage<net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant>storage()Returns the value of thestoragerecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface earth.terrarium.botarium.common.fluid.base.FluidContainer
getFirstFluid, internalExtract, internalInsert, isFluidValid, readSnapshot
-
Constructor Details
-
PlatformFluidItemHandler
public PlatformFluidItemHandler(ItemStackHolder stack, net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext context, net.fabricmc.fabric.api.transfer.v1.storage.Storage<net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant> storage) Creates an instance of aPlatformFluidItemHandlerrecord class.- Parameters:
stack- the value for thestackrecord componentcontext- the value for thecontextrecord componentstorage- the value for thestoragerecord component
-
-
Method Details
-
of
Description copied from interface:FluidContainerRetrieves an instance of FluidContainer for the given item stack. This method can be used to retrieve FluidContainers from Botarium and any other mod that uses the modloader's Fluid API.- Parameters:
stack- The item stack associated with the FluidContainer.- Returns:
- An instance of FluidContainer. Returns null if the item does not hold fluid.
-
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.
-
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 tank) - Specified by:
getTankCapacityin interfaceFluidContainer- Parameters:
tank- 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.
-
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.
-
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.
-
createSnapshot
- Specified by:
createSnapshotin interfaceFluidContainer- Returns:
- A
FluidSnapshotof the given state of theFluidContainer.
-
deserialize
public void deserialize(net.minecraft.nbt.CompoundTag nbt) Description copied from interface:SerializableDeserializes the information of an object from aCompoundTag.- Specified by:
deserializein interfaceSerializable- Parameters:
nbt- TheCompoundTagto deserialize from.
-
serialize
public net.minecraft.nbt.CompoundTag serialize(net.minecraft.nbt.CompoundTag nbt) Description copied from interface:SerializableSerializes the information of an object to aCompoundTag.- Specified by:
serializein interfaceSerializable- Parameters:
nbt- TheCompoundTagto serialize to.- Returns:
- The
CompoundTagthat was passed in but with the information of the object serialized added to it.
-
clearContent
public void clearContent()- Specified by:
clearContentin interfacenet.minecraft.world.Clearable
-
getContainerItem
public net.minecraft.world.item.ItemStack getContainerItem()- Specified by:
getContainerItemin interfaceItemFluidContainer- Returns:
- The
ItemStackthat is used as container item for this fluid container.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
stack
Returns the value of thestackrecord component.- Returns:
- the value of the
stackrecord component
-
context
public net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext context()Returns the value of thecontextrecord component.- Returns:
- the value of the
contextrecord component
-
storage
public net.fabricmc.fabric.api.transfer.v1.storage.Storage<net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant> storage()Returns the value of thestoragerecord component.- Returns:
- the value of the
storagerecord component
-