Class ToolSet.Builder

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

public static class ToolSet.Builder extends Object
Builder for constructing ToolSet instances with a fluent API.

This builder enables detailed configuration of tool sets with per-tool attack statistics, item properties, and custom creation logic.

Default Values:
  • Attack damage: 0.0F for all tools
  • Attack speed: 0.0F for all tools
  • Properties supplier: Item.Properties::new
  • Customizer: DefaultToolCustomizer.INSTANCE

Example Usage:


 // Create netherite tools with custom stats
 ToolSet netheriteTools = new ToolSet.Builder("netherite", Tiers.NETHERITE, new GenericAttributeHelper())
     .withToolStats(ToolType.AXE, 5.0F, 1.0F)  // More damage, faster axe
     .withToolStats(ToolType.HOE, -4.0F, 4.0F)    // Same as other hoes (tweaked because of attackDamageBonus)
     .withItemPropertiesSupplier(() -> new Item.Properties().fireResistant().rarity(Rarity.RARE))
     .build();
 
Since:
1.0.0
See Also:
  • Constructor Details

    • Builder

      public Builder(String name, net.minecraft.world.item.Tier tier)
      Constructs a new builder for a tool set with the specified base name and tier.
      Parameters:
      name - base name for tools (e.g., "iron"), will be appended with tool-specific suffixes
      tier - material tier for all tools, defines base durability, mining level, and base damage
      Throws:
      NullPointerException - if name, tier, or attributeHelper is null
      IllegalArgumentException - if name is empty or contains invalid characters
  • Method Details

    • withToolStats

      public ToolSet.Builder withToolStats(float[] damages, float[] speeds)
      Configures attack statistics for all tools using arrays.

      Array order must exactly match the ToolType.values() order: [SWORD, AXE, PICKAXE, HOE, SHOVEL]

      Note: Attack damage values are bonuses added to the tier's base damage. Attack speed values are modifiers applied to the base attack speed.

      Parameters:
      damages - attack damage bonuses for each tool type (added to tier base damage)
      speeds - attack speed modifiers for each tool type
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if array lengths don't match the number of tool types (expected: 5)
      See Also:
    • withToolStats

      public ToolSet.Builder withToolStats(ToolType type, float damage, float speed)
      Configures attack statistics for a specific tool type.

      Attack damage is added to the tier's base damage. Attack speed is a modifier applied to the base attack speed.

      Parameters:
      type - the tool type to configure
      damage - attack damage bonus (added to tier base damage)
      speed - attack speed modifier
      Returns:
      this builder for method chaining
      Throws:
      NullPointerException - if type is null
    • withVanillaBalance

      public ToolSet.Builder withVanillaBalance()
      Applies vanilla Minecraft balance values to all tools.

      Uses the standard damage bonuses and attack speeds from vanilla Minecraft, specifically matching iron-tier tool statistics.

      Applied Stats:
      Vanilla Iron Tool Statistics
      Tool TypeDamage BonusAttack Speed
      Sword+3.01.6
      Axe+6.00.9
      Pickaxe+1.01.2
      Shovel-2.03.0
      Hoe+1.51.0
      Returns:
      this builder for method chaining
    • withItemProperties

      public ToolSet.Builder withItemProperties(net.minecraft.world.item.Item.Properties properties)
      Warning: Sets shared item properties for all tools.

      This method reuses the same Item.Properties instance for all tools, which may cause issues if properties are mutated internally. For most cases, prefer withItemPropertiesSupplier(Supplier) which creates fresh properties for each tool.

      Parameters:
      properties - base properties applied to all tools
      Returns:
      this builder for method chaining
      Throws:
      NullPointerException - if properties is null
      See Also:
    • withItemPropertiesSupplier

      public ToolSet.Builder withItemPropertiesSupplier(Supplier<net.minecraft.world.item.Item.Properties> propertiesSupplier)
      Sets a supplier for item properties, called once per tool during creation.

      This is the preferred method for setting properties as it ensures each tool receives a fresh Item.Properties instance, avoiding potential mutation conflicts.

      Parameters:
      propertiesSupplier - supplier providing base properties for each tool
      Returns:
      this builder for method chaining
      Throws:
      NullPointerException - if propertiesSupplier is null
      See Also:
    • 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 customizer is null
      See Also:
    • withAttributeHelper

      public ToolSet.Builder withAttributeHelper(AttributeHelper attributeHelper)
    • 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