Record Class ScanToolData

java.lang.Object
java.lang.Record
com.ldtteam.structurize.util.ScanToolData
Record Components:
slots - the list of slot data.
currentSlotId - the currently selected slot id.
commandPos - the location of the linked command block.
dimension - the dimension of the linked command block.

public record ScanToolData(List<ScanToolData.Slot> slots, int currentSlotId, @Nullable net.minecraft.core.BlockPos commandPos, @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) extends Record
Data representing a set of scans in the scan tool.
  • Field Details

    • NUM_SLOTS

      public static final int NUM_SLOTS
      The number of scan slots. We keep 10 so that we can map them to 0-9 keys.
      See Also:
    • CODEC

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

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,ScanToolData> STREAM_CODEC
    • EMPTY

      public static ScanToolData EMPTY
  • Constructor Details

    • ScanToolData

      public ScanToolData(List<ScanToolData.Slot> slots, int currentSlotId, @Nullable @Nullable net.minecraft.core.BlockPos commandPos, @Nullable @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
      Creates an instance of a ScanToolData record class.
      Parameters:
      slots - the value for the slots record component
      currentSlotId - the value for the currentSlotId record component
      commandPos - the value for the commandPos record component
      dimension - the value for the dimension record component
  • Method Details

    • currentSlot

      public ScanToolData.Slot currentSlot()
      Gets the currently selected slot
      Returns:
      the slot data for the current slot
    • withCurrentSlot

      public ScanToolData withCurrentSlot(@Nullable @Nullable ScanToolData.Slot data)
      Saves the specified data in the current slot.
      Parameters:
      data - the new slot data.
      Returns:
      the new ScanToolData.
    • nextSlot

      public ScanToolData nextSlot()
      Moves to the next slot, wrapping back to the start if needed
    • prevSlot

      public ScanToolData prevSlot()
      Moves to the previous slot, wrapping to the end if needed
    • moveTo

      public ScanToolData moveTo(int slot)
      Moves to the specified slot number
      Parameters:
      slot - the new slot number
    • withCommandBlock

      public ScanToolData withCommandBlock(@Nullable @Nullable net.minecraft.world.level.block.entity.CommandBlockEntity commandBlock)
      Sets the command block position and dimension.
      Parameters:
      commandBlock - the command block entity.
      Returns:
      the updated ScanToolData.
    • readFromItemStack

      public static ScanToolData readFromItemStack(net.minecraft.world.item.ItemStack stack)
      Gets the ScanToolData from an ItemStack.
      Parameters:
      stack - the stack to query.
      Returns:
      the associated data or immutable empty instance.
    • writeToItemStack

      public void writeToItemStack(net.minecraft.world.item.ItemStack itemStack)
      Writes the ScanToolData into an ItemStack.
      Parameters:
      itemStack - the stack to save into.
    • updateItemStack

      public static ScanToolData updateItemStack(net.minecraft.world.item.ItemStack stack, UnaryOperator<ScanToolData> updater)
      Modifies the ScanToolData on an ItemStack.
      Parameters:
      stack - the stack to update.
      updater - the update actions to apply.
      Returns:
      the updated data (also stored on the stack).
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • slots

      public List<ScanToolData.Slot> slots()
      Returns the value of the slots record component.
      Returns:
      the value of the slots record component
    • currentSlotId

      public int currentSlotId()
      Returns the value of the currentSlotId record component.
      Returns:
      the value of the currentSlotId record component
    • commandPos

      @Nullable public @Nullable net.minecraft.core.BlockPos commandPos()
      Returns the value of the commandPos record component.
      Returns:
      the value of the commandPos record component
    • dimension

      @Nullable public @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension()
      Returns the value of the dimension record component.
      Returns:
      the value of the dimension record component