Class ArmorSet.Builder
- Enclosing class:
ArmorSet
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:- Durability factor: 0 (uses material default)
- Properties supplier:
Item.Properties::new
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:
-
Method Summary
Modifier and TypeMethodDescriptionaddPiece(ArmorPieceType piece) Adds a single armor piece type to the set.addPieces(Collection<ArmorPieceType> pieces) Adds multiple armor piece types to the set.build()Constructs the configuredArmorSet.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 armor item.withCustomizer(ArmorCustomizer customizer) Sets a custom armor creation strategy for specialized armor types.withDurabilityFactor(int durabilityFactor) Sets the durability multiplier for all armor pieces.
-
Method Details
-
addPiece
Adds a single armor piece type to the set.- Parameters:
piece- the piece to add (must not benull)- Returns:
- this builder
- Throws:
NullPointerException- ifpieceisnullIllegalArgumentException- if the piece was already added
-
addPieces
Adds multiple armor 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
-
withDurabilityFactor
Sets the durability multiplier for all armor pieces.The actual durability is computed as
material.durability() * factor.- Parameters:
durabilityFactor- the multiplier (must be positive)- Returns:
- this builder
-
globalPropertiesModifier
public ArmorSet.Builder globalPropertiesModifier(UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier) Sets a modifier for theItem.Propertiesused when creating each armor 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 ArmorSet.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 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- ifitemFactoryisnull- See Also:
-
build
Constructs the configuredArmorSet.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
-