Record Class ItemDefinition

java.lang.Object
java.lang.Record
fr.fidorial.item.ItemDefinition
Record Components:
key - the identifier the item is created and saved under
networkType - the vanilla item the client renders
components - the components every stack of this item starts with
All Implemented Interfaces:
DataComponentHolder

public record ItemDefinition(Key key, Key networkType, DataComponentMap components) extends Record implements DataComponentHolder
Everything the server needs to build an item a plugin invented.
Since:
0.1.0
  • Field Details

    • DEFAULT_MAX_STACK_SIZE

      public static final int DEFAULT_MAX_STACK_SIZE
      What an item stacks to when it says nothing about it.
      See Also:
  • Constructor Details

    • ItemDefinition

      public ItemDefinition(Key key, Key networkType, DataComponentMap components)
      Creates an instance of a ItemDefinition record class.
      Parameters:
      key - the value for the key record component
      networkType - the value for the networkType record component
      components - the value for the components record component
  • Method Details

    • builder

      public static ItemDefinition.Builder builder(Key key, Key networkType)
      Parameters:
      key - the identifier the item is created and saved under
      networkType - the vanilla item the client renders
      Returns:
      a builder pre-filled with the defaults of a plain, unstackable tool
      Since:
      0.1.0
    • toBuilder

      public ItemDefinition.Builder toBuilder()
      Returns:
      a builder pre-populated with this definition
      Since:
      0.1.0
    • 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.
    • key

      public Key key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • networkType

      public Key networkType()
      Returns the value of the networkType record component.
      Returns:
      the value of the networkType record component
    • components

      public DataComponentMap components()
      Returns the value of the components record component.
      Specified by:
      components in interface DataComponentHolder
      Returns:
      the value of the components record component