Package net.xun.armory.api.item.tools
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 Summary
ConstructorsConstructorDescriptionToolFactory(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. -
Method Summary
-
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, nevernullattackDamage- map of attack damage bonuses per tool type, nevernullattackSpeed- map of attack speed modifiers per tool type, nevernullpropertiesSupplier- supplier for item properties (called once per tool), nevernullconfigurator- customizer for tool item creation, nevernullattributeHelper- helper for applying combat attributes, nevernull- Throws:
NullPointerException- if any required parameter isnullIllegalArgumentException- if attack maps are missing entries for anyToolType
-
-
Method Details
-
getPieceType
Returns the piece type, which for tools is theToolTypeitself.- Specified by:
getPieceTypein interfaceItemPieceFactory<ToolType,net.minecraft.world.item.Item> - Parameters:
piece- the tool piece type- Returns:
- the piece type unchanged
-
create
Creates a tool item for the specified tool type.This method:
- Obtains fresh item properties from the supplier
- Calculates total attack damage (tier base + bonus)
- Applies combat attributes via
AttributeHelper - Delegates to the
ToolCustomizerfor item creation
- Specified by:
createin interfaceItemPieceFactory<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- ifpieceisnullIllegalStateException- if attack stats are missing for the tool typeIllegalArgumentException- if the customizer fails to create the item
-