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 - Customizer:
DefaultArmorCustomizer.INSTANCE
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Constructs the configuredArmorSet.withCustomizer(ArmorCustomizer customizer) Sets a custom armor creation strategy for specialized armor types.withDurabilityFactor(int durabilityFactor) Sets the durability multiplier for all armor pieces in the set.withItemProperties(net.minecraft.world.item.Item.Properties properties) Warning: Sets shared item properties for all armor pieces.withItemPropertiesSupplier(Supplier<net.minecraft.world.item.Item.Properties> propertiesSupplier) Sets a supplier for item properties, called once per armor piece during creation.
-
Constructor Details
-
Builder
public Builder(String name, net.minecraft.core.Holder<net.minecraft.world.item.ArmorMaterial> material) Constructs a new builder for an armor set with the specified base name and material.- Parameters:
name- base name for armor pieces (e.g., "iron"), will be appended with armor-specific suffixesmaterial- armor material holder defining protection values and toughness- Throws:
NullPointerException- ifnameormaterialisnullIllegalArgumentException- ifnameis empty or contains invalid characters
-
-
Method Details
-
withDurabilityFactor
Sets the durability multiplier for all armor pieces in the set.The final durability for each piece is calculated as:
Vanilla Reference Values:armor type base durability × durabilityFactorVanilla Durability Factors Material Durability Factor Leather 5 Chain 15 Iron 15 Gold 7 Diamond 33 Netherite 37 Vanilla Armor Type Base Durability Armor type Base Durability Helmet 11 Chestplate 16 Leggings 15 Boots 13 - Parameters:
durabilityFactor- multiplier for base armor type durability- Returns:
- this builder for method chaining
- Throws:
IllegalArgumentException- ifdurabilityFactoris negative
-
withItemProperties
Warning: Sets shared item properties for all armor pieces.This method reuses the same
Item.Propertiesinstance for all armor pieces, which may cause issues if properties are mutated internally. For most cases, preferwithItemPropertiesSupplier(Supplier)which creates fresh properties for each piece.- Parameters:
properties- base properties applied to all armor pieces- Returns:
- this builder for method chaining
- Throws:
NullPointerException- ifpropertiesisnull- See Also:
-
withItemPropertiesSupplier
public ArmorSet.Builder withItemPropertiesSupplier(Supplier<net.minecraft.world.item.Item.Properties> propertiesSupplier) Sets a supplier for item properties, called once per armor piece during creation.This is the preferred method for setting properties as it ensures each armor piece receives a fresh
Item.Propertiesinstance, avoiding potential mutation conflicts.- Parameters:
propertiesSupplier- supplier providing base properties for each armor piece- Returns:
- this builder for method chaining
- Throws:
NullPointerException- ifpropertiesSupplierisnull- See Also:
-
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- ifcustomizerisnull- 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
-