Record Class AbstractItemWithPosSelector.PosSelection

java.lang.Object
java.lang.Record
com.ldtteam.structurize.items.AbstractItemWithPosSelector.PosSelection
Enclosing class:
AbstractItemWithPosSelector

public static record AbstractItemWithPosSelector.PosSelection(Optional<net.minecraft.core.BlockPos> startPos, Optional<net.minecraft.core.BlockPos> endPos) extends Record
Data components for storing start and end pos
  • Field Details

  • Constructor Details

    • PosSelection

      public PosSelection(Optional<net.minecraft.core.BlockPos> startPos, Optional<net.minecraft.core.BlockPos> endPos)
      Creates an instance of a PosSelection record class.
      Parameters:
      startPos - the value for the startPos record component
      endPos - the value for the endPos record component
  • Method Details

    • hasSelection

      public boolean hasSelection()
      Returns:
      true if both start and end positions are set
    • setStartPos

      public AbstractItemWithPosSelector.PosSelection setStartPos(net.minecraft.core.BlockPos pos)
      For use with ItemStack.update(DataComponentType, Object, UnaryOperator)
    • setEndpos

      public AbstractItemWithPosSelector.PosSelection setEndpos(net.minecraft.core.BlockPos pos)
      For use with ItemStack.update(DataComponentType, Object, UnaryOperator)
    • setSelection

      public AbstractItemWithPosSelector.PosSelection setSelection(net.minecraft.core.BlockPos startPos, net.minecraft.core.BlockPos endPos)
      For use with ItemStack.update(DataComponentType, Object, UnaryOperator)
    • writeToItemStack

      public void writeToItemStack(net.minecraft.world.item.ItemStack itemStack)
      Writes this posSelection into given itemStack.
      See Also:
      • invalid reference
        BlockEntity#saveToItem(ItemStack, net.minecraft.core.HolderLookup.Provider)
    • readFromItemStack

      public static AbstractItemWithPosSelector.PosSelection readFromItemStack(net.minecraft.world.item.ItemStack itemStack)
      Returns:
      posSelection stored in given itemStack (or empty instance)
    • updateItemStack

      public static void updateItemStack(net.minecraft.world.item.ItemStack itemStack, UnaryOperator<AbstractItemWithPosSelector.PosSelection> updater)
      Performs updating of posSelection in given itemStack
    • 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.
    • startPos

      public Optional<net.minecraft.core.BlockPos> startPos()
      Returns the value of the startPos record component.
      Returns:
      the value of the startPos record component
    • endPos

      public Optional<net.minecraft.core.BlockPos> endPos()
      Returns the value of the endPos record component.
      Returns:
      the value of the endPos record component