Record Class PlatformFluidItemHandler
java.lang.Object
java.lang.Record
earth.terrarium.botarium.forge.fluid.PlatformFluidItemHandler
- All Implemented Interfaces:
FluidContainer,ItemFluidContainer,Serializable,net.minecraft.world.Clearable
public record PlatformFluidItemHandler(ItemStackHolder holder, net.minecraftforge.fluids.capability.IFluidHandlerItem handler)
extends Record
implements ItemFluidContainer
-
Constructor Summary
ConstructorsConstructorDescriptionPlatformFluidItemHandler(ItemStackHolder holder, net.minecraftforge.fluids.capability.IFluidHandlerItem handler) Creates an instance of aPlatformFluidItemHandlerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidcopy()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) net.minecraftforge.fluids.capability.IFluidHandlerItemhandler()Returns the value of thehandlerrecord component.final inthashCode()Returns a hash code value for this object.holder()Returns the value of theholderrecord component.longinsertFluid(FluidHolder fluid, boolean simulate) Inserts aFluidHolderinto the container.booleanisEmpty()booleanisFluidValid(int slot, FluidHolder fluidHolder) static PlatformFluidItemHandlerof(ItemStackHolder holder) 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.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, readSnapshot
-
Constructor Details
-
PlatformFluidItemHandler
public PlatformFluidItemHandler(ItemStackHolder holder, net.minecraftforge.fluids.capability.IFluidHandlerItem handler) Creates an instance of aPlatformFluidItemHandlerrecord class.- Parameters:
holder- the value for theholderrecord componenthandler- the value for thehandlerrecord 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:
holder- 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.
-
isFluidValid
- Specified by:
isFluidValidin interfaceFluidContainerfluidHolder- TheFluidHolderto check if can be inserted into.- Returns:
- Whether the given
FluidHoldercan be inserted into.
-
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). -
holder
Returns the value of theholderrecord component.- Returns:
- the value of the
holderrecord component
-
handler
public net.minecraftforge.fluids.capability.IFluidHandlerItem handler()Returns the value of thehandlerrecord component.- Returns:
- the value of the
handlerrecord component
-