Class ToolSet.Builder

java.lang.Object
net.xun.armory.api.item.tools.ToolSet.Builder
Enclosing class:
ToolSet

public static class ToolSet.Builder extends Object
Since:
1.0.0
  • Method Details

    • addPiece

      public ToolSet.Builder addPiece(ToolPieceType piece)
      Adds a single tool piece type to the set using its default stats.
      Parameters:
      piece - the piece to add (must not be null)
      Returns:
      this builder
      Throws:
      NullPointerException - if piece is null
      IllegalArgumentException - if the piece was already added
    • addPieces

      public ToolSet.Builder addPieces(Collection<ToolPieceType> pieces)
      Adds multiple tool piece types to the set.
      Parameters:
      pieces - the collection of pieces to add (must not be null)
      Returns:
      this builder
      Throws:
      NullPointerException - if the collection is null
      IllegalArgumentException - if any piece is a duplicate
    • overrideStats

      public ToolSet.Builder overrideStats(ToolPieceType piece, ToolStats stats)
      Overrides the default stats for a previously added piece.
      Parameters:
      piece - the piece whose stats to override
      stats - the new stats (attack damage and speed)
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the piece has not been added
    • globalPropertiesModifier

      public ToolSet.Builder globalPropertiesModifier(UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier)
      Sets a modifier for the Item.Properties used when creating each tool item.

      The provided function receives the default properties (initially an empty Properties instance) and can modify them as needed – for example, to set fire resistance, rarity, or custom durability.

      Parameters:
      propertiesModifier - a function that transforms the base properties
      Returns:
      this builder for method chaining
      Throws:
      NullPointerException - if propertiesModifier is null
    • globalAdditionalAttributes

      public ToolSet.Builder globalAdditionalAttributes(Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes)
      Adds a consumer that can further modify the ItemAttributeModifiers.Builder after the default tool attributes have been applied.

      This is useful for adding extra attribute modifiers (e.g., movement speed, knockback resistance) to all tools in the set.

      Parameters:
      additionalAttributes - consumer that receives the attribute builder
      Returns:
      this builder for method chaining
      Throws:
      NullPointerException - if additionalAttributes is null
    • withCustomizer

      public ToolSet.Builder withCustomizer(ToolCustomizer customizer)
      Sets a custom tool creation strategy for specialized tool implementations.

      This allows overriding the default tool creation behavior to implement custom tool classes, modified attribute handling, or additional properties.

      Parameters:
      customizer - tool creation strategy implementation
      Returns:
      this builder for method chaining
      Throws:
      NullPointerException - if itemFactory is null
      See Also:
    • build

      public ToolSet build()
      Constructs an immutable ToolSet with the current builder configuration.

      Validates all configuration parameters and creates a new ToolSet instance. The returned set is thread-safe and lazily initializes its tools.

      Returns:
      a new tool set with the configured properties
      Throws:
      IllegalStateException - if required configuration is missing or invalid