Class ArmorSet.Builder

java.lang.Object
net.xun.armory.api.item.armor.ArmorSet.Builder
Enclosing class:
ArmorSet

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

This builder enables configuration of shared properties across all armor pieces in a set, including durability multipliers, item properties, and custom creation logic.

Default Values:
  • Durability factor: 0 (uses material default)
  • Properties supplier: Item.Properties::new

Example Usage:


 // Create netherite armor with fire resistance
 ArmorSet netheriteArmor = new ArmorSet.Builder("netherite", NETHERITE_MATERIAL)
     .withDurabilityFactor(37)  // Standard netherite multiplier
     .withItemPropertiesSupplier(() -> new Item.Properties()
         .fireResistant()
         .rarity(Rarity.EPIC))
     .build();
 
Since:
1.0.0
See Also:
  • Method Details

    • addPiece

      public ArmorSet.Builder addPiece(ArmorPieceType piece)
      Adds a single armor piece type to the set.
      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 ArmorSet.Builder addPieces(Collection<ArmorPieceType> pieces)
      Adds multiple armor 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
    • withDurabilityFactor

      public ArmorSet.Builder withDurabilityFactor(int durabilityFactor)
      Sets the durability multiplier for all armor pieces.

      The actual durability is computed as material.durability() * factor.

      Parameters:
      durabilityFactor - the multiplier (must be positive)
      Returns:
      this builder
    • globalPropertiesModifier

      public ArmorSet.Builder globalPropertiesModifier(UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier)
      Sets a modifier for the Item.Properties used when creating each armor 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 ArmorSet.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 ArmorSet.Builder withCustomizer(ArmorCustomizer customizer)
      Sets a custom armor creation strategy for specialized armor types.

      This allows overriding the default armor creation behavior to implement custom armor classes, modified durability calculations, or additional properties.

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

      public ArmorSet build()
      Constructs the configured ArmorSet.

      Validates all configuration and creates a new ArmorSet instance with the specified properties. The returned ArmorSet is immutable.

      Returns:
      New armor set instance
      Throws:
      IllegalStateException - if required configuration is invalid