Record Class WrappedBlockFluidContainer
java.lang.Object
java.lang.Record
earth.terrarium.botarium.common.fluid.impl.WrappedBlockFluidContainer
- Record Components:
block- The block entity.container- The wrapped fluid container. Botarium provides a default implementation for this withSimpleFluidContainer.
- All Implemented Interfaces:
FluidContainer,Serializable,Updatable,net.minecraft.world.Clearable
public record WrappedBlockFluidContainer(net.minecraft.world.level.block.entity.BlockEntity block, FluidContainer container)
extends Record
implements FluidContainer, Updatable
Represents a wrapped fluid container for a block entity.
This class implements the FluidContainer interface and the Updatable interface.
It delegates fluid-related operations to the wrapped fluid container, and updates the block entity when the fluid is changed.
-
Constructor Summary
ConstructorsConstructorDescriptionWrappedBlockFluidContainer(net.minecraft.world.level.block.entity.BlockEntity block, FluidContainer container) Creates an instance of aWrappedBlockFluidContainerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleannet.minecraft.world.level.block.entity.BlockEntityblock()Returns the value of theblockrecord component.voidReturns the value of thecontainerrecord component.copy()voiddeserialize(net.minecraft.nbt.CompoundTag tag) 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.intgetSize()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 tag) Serializes the information of an object to aCompoundTag.voidsetFluid(int slot, FluidHolder fluid) Sets a givenFluidHolderto a slot in the container.final StringtoString()Returns a string representation of this record class.voidupdate()Called when the operation has been completed and the data has been updated.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
-
Constructor Details
-
WrappedBlockFluidContainer
public WrappedBlockFluidContainer(net.minecraft.world.level.block.entity.BlockEntity block, FluidContainer container) Creates an instance of aWrappedBlockFluidContainerrecord 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:
- Whether 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:
- 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.
-
readSnapshot
Description copied from interface:FluidContainerSets theFluidContainerwith the given state ofFluidSnapshot.- Specified by:
readSnapshotin interfaceFluidContainer- Parameters:
snapshot- TheFluidSnapshotto set theFluidContainerto.
-
serialize
public net.minecraft.nbt.CompoundTag serialize(net.minecraft.nbt.CompoundTag tag) Description copied from interface:SerializableSerializes the information of an object to aCompoundTag.- Specified by:
serializein interfaceSerializable- Parameters:
tag- TheCompoundTagto serialize to.- Returns:
- The
CompoundTagthat was passed in but with the information of the object serialized added to it.
-
deserialize
public void deserialize(net.minecraft.nbt.CompoundTag tag) Description copied from interface:SerializableDeserializes the information of an object from aCompoundTag.- Specified by:
deserializein interfaceSerializable- Parameters:
tag- TheCompoundTagto deserialize from.
-
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). -
block
public net.minecraft.world.level.block.entity.BlockEntity block()Returns the value of theblockrecord component.- Returns:
- the value of the
blockrecord component
-
container
Returns the value of thecontainerrecord component.- Returns:
- the value of the
containerrecord component
-