Class ToolFactory

java.lang.Object
net.xun.armory.api.item.tools.ToolFactory
All Implemented Interfaces:
ItemPieceFactory<ToolType,net.minecraft.world.item.Item>

public class ToolFactory extends Object implements ItemPieceFactory<ToolType,net.minecraft.world.item.Item>
Factory implementation that creates tool items for a complete tool set.

This class bridges the ToolSet configuration with the piece-wise creation pattern required by ItemPieceFactory. It applies shared configuration (tier, attack stats, properties) to each tool while delegating the actual item creation to a ToolCustomizer.

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

Since:
1.0.0
See Also:
  • Constructor Details

    • ToolFactory

      public ToolFactory(net.minecraft.world.item.Tier tier, EnumMap<ToolType,Float> attackDamage, EnumMap<ToolType,Float> attackSpeed, Supplier<net.minecraft.world.item.Item.Properties> propertiesSupplier, ToolCustomizer configurator, AttributeHelper attributeHelper)
      Constructs a new tool factory with the specified configuration.
      Parameters:
      tier - material tier for all tools, never null
      attackDamage - map of attack damage bonuses per tool type, never null
      attackSpeed - map of attack speed modifiers per tool type, never null
      propertiesSupplier - supplier for item properties (called once per tool), never null
      configurator - customizer for tool item creation, never null
      attributeHelper - helper for applying combat attributes, never null
      Throws:
      NullPointerException - if any required parameter is null
      IllegalArgumentException - if attack maps are missing entries for any ToolType
  • Method Details

    • getPieceType

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

      public net.minecraft.world.item.Item create(ToolType piece)
      Creates a tool item for the specified tool type.

      This method:

      1. Obtains fresh item properties from the supplier
      2. Calculates total attack damage (tier base + bonus)
      3. Applies combat attributes via AttributeHelper
      4. Delegates to the ToolCustomizer for item creation
      Specified by:
      create in interface ItemPieceFactory<ToolType,net.minecraft.world.item.Item>
      Parameters:
      piece - the type of tool to create
      Returns:
      a configured tool item for the specified piece
      Throws:
      NullPointerException - if piece is null
      IllegalStateException - if attack stats are missing for the tool type
      IllegalArgumentException - if the customizer fails to create the item