Class ToolSet.Builder
- Enclosing class:
ToolSet
ToolSet instances with a fluent API.
This builder enables detailed configuration of tool sets with per-tool attack statistics, item properties, and custom creation logic.
Default Values:
- Attack damage: 0.0F for all tools
- Attack speed: 0.0F for all tools
- Properties supplier:
Item.Properties::new - Customizer:
DefaultToolCustomizer.INSTANCE
Example Usage:
// Create netherite tools with custom stats
ToolSet netheriteTools = new ToolSet.Builder("netherite", Tiers.NETHERITE, new GenericAttributeHelper())
.withToolStats(ToolType.AXE, 5.0F, 1.0F) // More damage, faster axe
.withToolStats(ToolType.HOE, -4.0F, 4.0F) // Same as other hoes (tweaked because of attackDamageBonus)
.withItemPropertiesSupplier(() -> new Item.Properties().fireResistant().rarity(Rarity.RARE))
.build();
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(String name, net.minecraft.world.item.Tier tier, AttributeHelper attributeHelper) Constructs a new builder for a tool set with the specified base name and tier. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Constructs an immutableToolSetwith the current builder configuration.withCustomizer(ToolCustomizer customizer) Sets a custom tool creation strategy for specialized tool implementations.withItemProperties(net.minecraft.world.item.Item.Properties properties) Warning: Sets shared item properties for all tools.withItemPropertiesSupplier(Supplier<net.minecraft.world.item.Item.Properties> propertiesSupplier) Sets a supplier for item properties, called once per tool during creation.withToolStats(float[] damages, float[] speeds) Configures attack statistics for all tools using arrays.withToolStats(ToolType type, float damage, float speed) Configures attack statistics for a specific tool type.Applies vanilla Minecraft balance values to all tools.
-
Constructor Details
-
Builder
Constructs a new builder for a tool set with the specified base name and tier.- Parameters:
name- base name for tools (e.g., "iron"), will be appended with tool-specific suffixestier- material tier for all tools, defines base durability, mining level, and base damageattributeHelper- helper for applying combat attributes to tools- Throws:
NullPointerException- ifname,tier, orattributeHelperisnullIllegalArgumentException- ifnameis empty or contains invalid characters
-
-
Method Details
-
withToolStats
Configures attack statistics for all tools using arrays.Array order must exactly match the
ToolType.values()order: [SWORD, AXE, PICKAXE, HOE, SHOVEL]Note: Attack damage values are bonuses added to the tier's base damage. Attack speed values are modifiers applied to the base attack speed.
- Parameters:
damages- attack damage bonuses for each tool type (added to tier base damage)speeds- attack speed modifiers for each tool type- Returns:
- this builder for method chaining
- Throws:
IllegalArgumentException- if array lengths don't match the number of tool types (expected: 5)- See Also:
-
withToolStats
Configures attack statistics for a specific tool type.Attack damage is added to the tier's base damage. Attack speed is a modifier applied to the base attack speed.
- Parameters:
type- the tool type to configuredamage- attack damage bonus (added to tier base damage)speed- attack speed modifier- Returns:
- this builder for method chaining
- Throws:
NullPointerException- iftypeisnull
-
withVanillaBalance
Applies vanilla Minecraft balance values to all tools.Uses the standard damage bonuses and attack speeds from vanilla Minecraft, specifically matching iron-tier tool statistics.
Applied Stats:Vanilla Iron Tool Statistics Tool Type Damage Bonus Attack Speed Sword +3.0 1.6 Axe +6.0 0.9 Pickaxe +1.0 1.2 Shovel -2.0 3.0 Hoe +1.5 1.0 - Returns:
- this builder for method chaining
-
withItemProperties
Warning: Sets shared item properties for all tools.This method reuses the same
Item.Propertiesinstance for all tools, which may cause issues if properties are mutated internally. For most cases, preferwithItemPropertiesSupplier(Supplier)which creates fresh properties for each tool.- Parameters:
properties- base properties applied to all tools- Returns:
- this builder for method chaining
- Throws:
NullPointerException- ifpropertiesisnull- See Also:
-
withItemPropertiesSupplier
public ToolSet.Builder withItemPropertiesSupplier(Supplier<net.minecraft.world.item.Item.Properties> propertiesSupplier) Sets a supplier for item properties, called once per tool during creation.This is the preferred method for setting properties as it ensures each tool receives a fresh
Item.Propertiesinstance, avoiding potential mutation conflicts.- Parameters:
propertiesSupplier- supplier providing base properties for each tool- Returns:
- this builder for method chaining
- Throws:
NullPointerException- ifpropertiesSupplierisnull- See Also:
-
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- ifcustomizerisnull- 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
-