Record Class ItemTagTool.TagData

java.lang.Object
java.lang.Record
com.ldtteam.structurize.items.ItemTagTool.TagData
Enclosing class:
ItemTagTool

public static record ItemTagTool.TagData(Optional<net.minecraft.core.BlockPos> anchorPos, Optional<String> currentTag) extends Record
Data components for storing start and end pos
  • Field Details

    • EMPTY

      public static final ItemTagTool.TagData EMPTY
    • CODEC

      public static final com.mojang.serialization.Codec<ItemTagTool.TagData> CODEC
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,ItemTagTool.TagData> STREAM_CODEC
  • Constructor Details

    • TagData

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

    • setAnchorPos

      public ItemTagTool.TagData setAnchorPos(net.minecraft.core.BlockPos pos)
      For use with ItemStack.update(DataComponentType, Object, UnaryOperator)
    • setCurrentTag

      public ItemTagTool.TagData setCurrentTag(String currentTag)
      For use with ItemStack.update(DataComponentType, Object, UnaryOperator)
    • writeToItemStack

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

      public static ItemTagTool.TagData readFromItemStack(net.minecraft.world.item.ItemStack itemStack)
      Returns:
      tagData stored in given itemStack (or empty instance)
    • updateItemStack

      public static void updateItemStack(net.minecraft.world.item.ItemStack itemStack, UnaryOperator<ItemTagTool.TagData> updater)
      Performs updating of tagData 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.
    • anchorPos

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

      public Optional<String> currentTag()
      Returns the value of the currentTag record component.
      Returns:
      the value of the currentTag record component