Record Class ItemData

java.lang.Object
java.lang.Record
fr.robie.machineengine.api.item.ItemData
Record Components:
item - the item id, e.g. minecraft:iron_ingot or a CraftEngine item id
data - the serialized single item (never mutated)

public record ItemData(@NotNull net.kyori.adventure.key.Key item, byte @NotNull [] data) extends Record
Which item a Items.ITEM resource is: the item id plus the platform's serialized form of one such item (Paper: ItemStack#serializeAsBytes). Two items stack in a machine exactly when both are equal.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemData(@NotNull net.kyori.adventure.key.Key item, byte @NotNull [] data)
    Creates an instance of a ItemData record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte @NotNull []
    Returns the value of the data record component.
    boolean
    equals(Object other)
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    @NotNull net.kyori.adventure.key.Key
    Returns the value of the item record component.
    @NotNull String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ItemData

      public ItemData(@NotNull @NotNull net.kyori.adventure.key.Key item, byte @NotNull [] data)
      Creates an instance of a ItemData record class.
      Parameters:
      item - the value for the item record component
      data - the value for the data record component
  • Method Details

    • data

      public byte @NotNull [] data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component
    • equals

      public boolean equals(Object other)
      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:
      other - the object with which to compare
      Returns:
      true if this object is the same as the other argument; false otherwise.
    • hashCode

      public 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
    • toString

      @NotNull public @NotNull 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
    • item

      @NotNull public @NotNull net.kyori.adventure.key.Key item()
      Returns the value of the item record component.
      Returns:
      the value of the item record component