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:

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:
  • Constructor Details

    • Builder

      public Builder(String name, net.minecraft.core.Holder<net.minecraft.world.item.ArmorMaterial> material)
      Constructs a new builder for an armor set with the specified base name and material.
      Parameters:
      name - base name for armor pieces (e.g., "iron"), will be appended with armor-specific suffixes
      material - armor material holder defining protection values and toughness
      Throws:
      NullPointerException - if name or material is null
      IllegalArgumentException - if name is empty or contains invalid characters
  • Method Details

    • withDurabilityFactor

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

      The final durability for each piece is calculated as: armor type base durability × durabilityFactor

      Vanilla Reference Values:
      Vanilla Durability Factors
      MaterialDurability Factor
      Leather5
      Chain15
      Iron15
      Gold7
      Diamond33
      Netherite37
      Vanilla Armor Type Base Durability
      Armor typeBase Durability
      Helmet11
      Chestplate16
      Leggings15
      Boots13
      Parameters:
      durabilityFactor - multiplier for base armor type durability
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if durabilityFactor is negative
    • withItemProperties

      public ArmorSet.Builder withItemProperties(net.minecraft.world.item.Item.Properties properties)
      Warning: Sets shared item properties for all armor pieces.

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

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

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

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

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