Record Class WrappedItemFluidContainer
java.lang.Object
java.lang.Record
earth.terrarium.botarium.common.fluid.impl.WrappedItemFluidContainer
- Record Components:
stack- The item stack.container- The wrapped fluid container. Botarium provides a default implementation for this withSimpleFluidContainer.
- All Implemented Interfaces:
FluidContainer,ItemFluidContainer,Serializable,Updatable,net.minecraft.world.Clearable
public record WrappedItemFluidContainer(net.minecraft.world.item.ItemStack stack, FluidContainer container)
extends Record
implements ItemFluidContainer, Updatable
Represents a wrapped fluid container for an item.
This class implements the FluidContainer interface and the Updatable interface.
It delegates fluid-related operations to the wrapped fluid container, and updates the item when the fluid is changed.
-
Constructor Summary
ConstructorsConstructorDescriptionWrappedItemFluidContainer(net.minecraft.world.item.ItemStack stack, FluidContainer container) Creates an instance of aWrappedItemFluidContainerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidReturns the value of thecontainerrecord 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 tankSlot) final inthashCode()Returns a hash code value for this object.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 fluids, 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) voidreadSnapshot(FluidSnapshot snapshot) Sets theFluidContainerwith the given state ofFluidSnapshot.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.net.minecraft.world.item.ItemStackstack()Returns the value of thestackrecord component.final StringtoString()Returns a string representation of this record class.voidupdate()Called when the operation has been completed and the data has been updated.
-
Constructor Details
-
WrappedItemFluidContainer
public WrappedItemFluidContainer(net.minecraft.world.item.ItemStack stack, FluidContainer container) Creates an instance of aWrappedItemFluidContainerrecord class.
-
-
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.
-
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
-
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.
-
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
-
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:
- Weather or not the container is empty.
-
copy
- Specified by:
copyin interfaceFluidContainer- Returns:
- A copy of the container.
-
getTankCapacity
public long getTankCapacity(int tankSlot) - Specified by:
getTankCapacityin interfaceFluidContainer- Parameters:
tankSlot- 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:
- Weather can be inserted into.
-
allowsExtraction
public boolean allowsExtraction()- Specified by:
allowsExtractionin interfaceFluidContainer- Returns:
- Weather can be extracted from.
-
createSnapshot
- Specified by:
createSnapshotin interfaceFluidContainer- Returns:
- A
FluidSnapshotof the given state of theFluidContainer.
-
readSnapshot
Description copied from interface:FluidContainerSets theFluidContainerwith the given state ofFluidSnapshot.- Specified by:
readSnapshotin interfaceFluidContainer- Parameters:
snapshot- TheFluidSnapshotto set theFluidContainerto.
-
isFluidValid
- Specified by:
isFluidValidin interfaceFluidContainerfluidHolder- TheFluidHolderto check if can be inserted into.- Returns:
- Weather the given
FluidHoldercan be inserted into.
-
getContainerItem
public net.minecraft.world.item.ItemStack getContainerItem()- Specified by:
getContainerItemin interfaceItemFluidContainer- Returns:
- The
ItemStackthat is used as container item for this fluid container.
-
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.
-
update
public void update()Description copied from interface:UpdatableCalled when the operation has been completed and the data has been updated. -
clearContent
public void clearContent()- Specified by:
clearContentin interfacenet.minecraft.world.Clearable
-
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
public net.minecraft.world.item.ItemStack stack()Returns the value of thestackrecord component.- Returns:
- the value of the
stackrecord component
-
container
Returns the value of thecontainerrecord component.- Returns:
- the value of the
containerrecord component
-