Class ArmorFactory

java.lang.Object
net.xun.armory.api.item.armor.ArmorFactory
All Implemented Interfaces:
ItemPieceFactory<ArmorType,net.minecraft.world.item.ArmorItem>

public class ArmorFactory extends Object implements ItemPieceFactory<ArmorType,net.minecraft.world.item.ArmorItem>
Factory implementation that creates armor items for a complete armor set.

This class bridges the ArmorSet configuration with the piece-wise creation pattern required by ItemPieceFactory. It applies shared configuration (material, durability, properties) to each armor piece while delegating the actual item creation to an ArmorCustomizer.

Lifecycle: Instances are created by ArmorSet and used during registration to lazily create individual armor pieces.

Since:
2.0.0
See Also:
  • Constructor Details

    • ArmorFactory

      public ArmorFactory(net.minecraft.core.Holder<net.minecraft.world.item.ArmorMaterial> material, int durabilityFactor, Supplier<net.minecraft.world.item.Item.Properties> propertiesSupplier, ArmorCustomizer configurator)
      Constructs a new armor factory with the specified configuration.
      Parameters:
      material - holder for the armor material, never null
      durabilityFactor - multiplier for base material durability
      propertiesSupplier - supplier for item properties (called once per piece)
      configurator - customizer for armor item creation, never null
      Throws:
      NullPointerException - if any required parameter is null
  • Method Details

    • getPieceType

      public PieceType getPieceType(ArmorType piece)
      Returns the piece type, which for armor is the ArmorType itself.
      Specified by:
      getPieceType in interface ItemPieceFactory<ArmorType,net.minecraft.world.item.ArmorItem>
      Parameters:
      piece - the armor piece type
      Returns:
      the piece type unchanged
    • create

      public net.minecraft.world.item.ArmorItem create(ArmorType piece)
      Creates an armor item for the specified piece type.

      This method:

      1. Obtains fresh item properties from the supplier
      2. Delegates to the configured ArmorCustomizer for item creation
      3. Returns a fully configured armor item
      Specified by:
      create in interface ItemPieceFactory<ArmorType,net.minecraft.world.item.ArmorItem>
      Parameters:
      piece - the type of armor piece to create
      Returns:
      a configured armor item for the specified piece
      Throws:
      NullPointerException - if piece is null
      IllegalStateException - if the customizer fails to create the item