Record Class PlatformBlockFluidHandler

java.lang.Object
java.lang.Record
earth.terrarium.botarium.forge.fluid.PlatformBlockFluidHandler
All Implemented Interfaces:
FluidContainer, Serializable, net.minecraft.world.Clearable

public record PlatformBlockFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler handler) extends Record implements FluidContainer
  • Constructor Details

    • PlatformBlockFluidHandler

      public PlatformBlockFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler handler)
      Creates an instance of a PlatformBlockFluidHandler record class.
      Parameters:
      handler - the value for the handler record component
  • Method Details

    • of

      @Nullable public static @Nullable PlatformBlockFluidHandler of(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable @Nullable net.minecraft.core.Direction direction)
      Description copied from interface: FluidContainer
      Retrieves an instance of FluidContainer for the given level, position, state, entity, and direction. This method can be used to retrieve FluidContainers from Botarium and any other mod that uses the modloader's Fluid API.
      Parameters:
      level - The level of the FluidContainer.
      pos - The position of the FluidContainer.
      state - The block state of the FluidContainer.
      entity - The block entity associated with the FluidContainer (can be null).
      direction - The direction of the FluidContainer (can be null).
      Returns:
      An instance of FluidContainer. Returns null if the block does not hold fluid.
    • 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:
      Whether 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:
      Whether can be inserted into.
    • allowsExtraction

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

      public FluidSnapshot createSnapshot()
      Specified by:
      createSnapshot in interface FluidContainer
      Returns:
      A FluidSnapshot of the given state of the FluidContainer.
    • 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.
    • 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:
      Whether the given FluidHolder can be inserted into.
    • 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
    • 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.
    • handler

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