Record Class ToolPieceType

java.lang.Object
java.lang.Record
net.xun.armory.api.item.tools.ToolPieceType
Record Components:
nameSuffix - the suffix appended to the set name to form the registry ID
defaultStats - the default attack damage and speed for this piece
itemFactory - the factory that creates the actual item instance
propertiesModifier - a per‑piece modifier for Item.Properties
additionalAttributes - a per‑piece consumer for additional attribute modifiers
All Implemented Interfaces:
PieceType

public record ToolPieceType(String nameSuffix, ToolStats defaultStats, ToolItemFactory itemFactory, UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier, Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes) extends Record implements PieceType
Represents a specific type of tool piece (e.g., sword, axe) with its own naming, default stats, item factory, and property modifiers.

Instances are typically defined as constants (e.g., VanillaToolPieces.SWORD) and used to build a ToolSet. Each piece defines how an item is created and how its properties and attributes are configured.

Since:
3.0.0
  • Constructor Details

    • ToolPieceType

      public ToolPieceType(String nameSuffix, ToolStats defaultStats, ToolItemFactory itemFactory, UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier, Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes)
      Creates an instance of a ToolPieceType record class.
      Parameters:
      nameSuffix - the value for the nameSuffix record component
      defaultStats - the value for the defaultStats record component
      itemFactory - the value for the itemFactory record component
      propertiesModifier - the value for the propertiesModifier record component
      additionalAttributes - the value for the additionalAttributes record component
  • Method Details

    • getNameSuffix

      public String getNameSuffix()
      Description copied from interface: PieceType
      Gets the naming suffix for this piece type.

      The suffix is appended to a base name to create the full registry name for an item. It should typically start with an underscore ("_") to separate it from the base name, following Minecraft's naming conventions.

      Examples:

      • "_sword" for swords
      • "_helmet" for helmets
      • "_chestplate" for chestplates
      Specified by:
      getNameSuffix in interface PieceType
      Returns:
      the naming suffix for this piece type, never null
    • createItem

      public net.minecraft.world.item.Item createItem(ToolContext context, net.minecraft.world.item.Item.Properties properties)
      Creates an item using this piece's factory and the provided context/properties. This method does NOT apply any properties modifiers; it expects the properties to already be final.
    • builder

      public static ToolPieceType.Builder builder(String suffix)
      Fluent builder for ToolPieceType.
    • 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.
    • nameSuffix

      public String nameSuffix()
      Returns the value of the nameSuffix record component.
      Returns:
      the value of the nameSuffix record component
    • defaultStats

      public ToolStats defaultStats()
      Returns the value of the defaultStats record component.
      Returns:
      the value of the defaultStats record component
    • itemFactory

      public ToolItemFactory itemFactory()
      Returns the value of the itemFactory record component.
      Returns:
      the value of the itemFactory record component
    • propertiesModifier

      public UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier()
      Returns the value of the propertiesModifier record component.
      Returns:
      the value of the propertiesModifier record component
    • additionalAttributes

      public Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes()
      Returns the value of the additionalAttributes record component.
      Returns:
      the value of the additionalAttributes record component