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 Details

    • PlatformFluidItemHandler

      public PlatformFluidItemHandler(ItemStackHolder holder, net.minecraftforge.fluids.capability.IFluidHandlerItem handler)
      Creates an instance of a PlatformFluidItemHandler record class.
      Parameters:
      holder - the value for the holder record component
      handler - the value for the handler record component
  • Method Details

    • of

      @Nullable public static PlatformFluidItemHandler of(ItemStackHolder holder)
    • insertFluid

      public long insertFluid(FluidHolder fluid, boolean simulate)
      Description copied from interface: FluidContainer
      Inserts a FluidHolder into the container.
      Specified by:
      insertFluid in interface FluidContainer
      Parameters:
      fluid - The FluidHolder to 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

      public FluidHolder extractFluid(FluidHolder fluid, boolean simulate)
      Description copied from interface: FluidContainer
      Extracts a FluidHolder from the container.
      Specified by:
      extractFluid in interface FluidContainer
      Parameters:
      fluid - The FluidHolder to be extracted from the container.
      simulate - If true, the container will not be modified.
      Returns:
      The FluidHolder that was extracted from the container.
    • setFluid

      public void setFluid(int slot, FluidHolder fluid)
      Description copied from interface: FluidContainer
      Sets a given FluidHolder to a slot in the container.
      Specified by:
      setFluid in interface FluidContainer
      Parameters:
      slot - The slot to set the fluid in.
      fluid - The FluidHolder to set in the slot.
    • getFluids

      public List<FluidHolder> getFluids()
      Specified by:
      getFluids in interface FluidContainer
      Returns:
      A List of FluidHolder in the container.
    • getSize

      public int getSize()
      Specified by:
      getSize in interface FluidContainer
      Returns:
      The amount of slots in the container.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface FluidContainer
      Returns:
      Weather or not the container is empty.
    • copy

      public FluidContainer copy()
      Specified by:
      copy in interface FluidContainer
      Returns:
      A copy of the container.
    • getTankCapacity

      public long getTankCapacity(int tank)
      Specified by:
      getTankCapacity in interface FluidContainer
      Parameters:
      tank - The slot to get the capacity of.
      Returns:
      The capacity of the given slot.
    • fromContainer

      public void fromContainer(FluidContainer container)
      Description copied from interface: FluidContainer
      Sets the container to the same values as the given container.
      Specified by:
      fromContainer in interface FluidContainer
      Parameters:
      container - The container to copy the fluids from.
    • extractFromSlot

      public long extractFromSlot(FluidHolder fluidHolder, FluidHolder toInsert, Runnable snapshot)
      Description copied from interface: FluidContainer
      Extracts a fluid from one FluidHolder into another.
      Specified by:
      extractFromSlot in interface FluidContainer
      Parameters:
      fluidHolder - The FluidHolder to extract from.
      toInsert - The FluidHolder to 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:
      allowsInsertion in interface FluidContainer
      Returns:
      Weather can be inserted into.
    • allowsExtraction

      public boolean allowsExtraction()
      Specified by:
      allowsExtraction in interface FluidContainer
      Returns:
      Weather can be extracted from.
    • createSnapshot

      public FluidSnapshot createSnapshot()
      Specified by:
      createSnapshot in interface FluidContainer
      Returns:
      A FluidSnapshot of the given state of the FluidContainer.
    • isFluidValid

      public boolean isFluidValid(int slot, FluidHolder fluidHolder)
      Specified by:
      isFluidValid in interface FluidContainer
      fluidHolder - The FluidHolder to check if can be inserted into.
      Returns:
      Weather the given FluidHolder can be inserted into.
    • deserialize

      public void deserialize(net.minecraft.nbt.CompoundTag nbt)
      Description copied from interface: Serializable
      Deserializes the information of an object from a CompoundTag.
      Specified by:
      deserialize in interface Serializable
      Parameters:
      nbt - The CompoundTag to deserialize from.
    • serialize

      public net.minecraft.nbt.CompoundTag serialize(net.minecraft.nbt.CompoundTag nbt)
      Description copied from interface: Serializable
      Serializes the information of an object to a CompoundTag.
      Specified by:
      serialize in interface Serializable
      Parameters:
      nbt - The CompoundTag to serialize to.
      Returns:
      The CompoundTag that was passed in but with the information of the object serialized added to it.
    • clearContent

      public void clearContent()
      Specified by:
      clearContent in interface net.minecraft.world.Clearable
    • getContainerItem

      public net.minecraft.world.item.ItemStack getContainerItem()
      Specified by:
      getContainerItem in interface ItemFluidContainer
      Returns:
      The ItemStack that is used as container item for this fluid container.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • holder

      public ItemStackHolder holder()
      Returns the value of the holder record component.
      Returns:
      the value of the holder record component
    • handler

      public net.minecraftforge.fluids.capability.IFluidHandlerItem handler()
      Returns the value of the handler record component.
      Returns:
      the value of the handler record component