Package net.xun.armory.api.item.tools
Class ToolSet.Builder
java.lang.Object
net.xun.armory.api.item.tools.ToolSet.Builder
- Enclosing class:
ToolSet
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionaddPiece(ToolPieceType piece) Adds a single tool piece type to the set using its default stats.addPieces(Collection<ToolPieceType> pieces) Adds multiple tool piece types to the set.build()Constructs an immutableToolSetwith the current builder configuration.globalAdditionalAttributes(Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes) Adds a consumer that can further modify theItemAttributeModifiers.Builderafter the default tool attributes have been applied.globalPropertiesModifier(UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier) Sets a modifier for theItem.Propertiesused when creating each tool item.overrideStats(ToolPieceType piece, ToolStats stats) Overrides the default stats for a previously added piece.withCustomizer(ToolCustomizer customizer) Sets a custom tool creation strategy for specialized tool implementations.
-
Method Details
-
addPiece
Adds a single tool piece type to the set using its default stats.- Parameters:
piece- the piece to add (must not benull)- Returns:
- this builder
- Throws:
NullPointerException- ifpieceisnullIllegalArgumentException- if the piece was already added
-
addPieces
Adds multiple tool piece types to the set.- Parameters:
pieces- the collection of pieces to add (must not benull)- Returns:
- this builder
- Throws:
NullPointerException- if the collection isnullIllegalArgumentException- if any piece is a duplicate
-
overrideStats
Overrides the default stats for a previously added piece.- Parameters:
piece- the piece whose stats to overridestats- the new stats (attack damage and speed)- Returns:
- this builder
- Throws:
IllegalArgumentException- if the piece has not been added
-
globalPropertiesModifier
public ToolSet.Builder globalPropertiesModifier(UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier) Sets a modifier for theItem.Propertiesused when creating each tool item.The provided function receives the default properties (initially an empty
Propertiesinstance) 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- ifpropertiesModifierisnull
-
globalAdditionalAttributes
public ToolSet.Builder globalAdditionalAttributes(Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes) Adds a consumer that can further modify theItemAttributeModifiers.Builderafter 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- ifadditionalAttributesisnull
-
withCustomizer
Sets a custom tool creation strategy for specialized tool implementations.This allows overriding the default tool creation behavior to implement custom tool classes, modified attribute handling, or additional properties.
- Parameters:
customizer- tool creation strategy implementation- Returns:
- this builder for method chaining
- Throws:
NullPointerException- ifitemFactoryisnull- See Also:
-
build
Constructs an immutableToolSetwith the current builder configuration.Validates all configuration parameters and creates a new
ToolSetinstance. The returned set is thread-safe and lazily initializes its tools.- Returns:
- a new tool set with the configured properties
- Throws:
IllegalStateException- if required configuration is missing or invalid
-