Package net.xun.armory.api.item.tools
Record Class ToolContext
java.lang.Object
java.lang.Record
net.xun.armory.api.item.tools.ToolContext
- Record Components:
setName- the base name of the tool settier- the material tier (durability, mining level)statsByPiece- a map from piece type to itsToolStatspropertiesModifier- a global modifier for item propertiesadditionalAttributes- a global consumer for extra attribute modifiers
public record ToolContext(String setName, net.minecraft.world.item.Tier tier, Map<ToolPieceType,ToolStats> statsByPiece, UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier, Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes)
extends Record
Immutable context object holding all configuration parameters for a tool set.
This record encapsulates the set name, tier, per‑piece stats, and property modifiers
used during tool creation. It provides methods to apply these configurations to
Item.Properties and to retrieve stats for a specific piece.
- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionToolContext(String setName, net.minecraft.world.item.Tier tier, Map<ToolPieceType, ToolStats> statsByPiece, UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier, Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes) Creates an instance of aToolContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionConsumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> Returns the value of theadditionalAttributesrecord component.net.minecraft.world.item.Item.PropertiesapplyProperties(ToolPieceType piece, net.minecraft.world.item.Item.Properties base) Applies all property modifiers (set-level and piece-level) and builds the final attribute modifiers.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.UnaryOperator<net.minecraft.world.item.Item.Properties> Returns the value of thepropertiesModifierrecord component.setName()Returns the value of thesetNamerecord component.Returns the value of thestatsByPiecerecord component.statsFor(ToolPieceType piece) Retrieves theToolStatsfor the given piece.net.minecraft.world.item.Tiertier()Returns the value of thetierrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ToolContext
public ToolContext(String setName, net.minecraft.world.item.Tier tier, Map<ToolPieceType, ToolStats> statsByPiece, UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier, Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes) Creates an instance of aToolContextrecord class.- Parameters:
setName- the value for thesetNamerecord componenttier- the value for thetierrecord componentstatsByPiece- the value for thestatsByPiecerecord componentpropertiesModifier- the value for thepropertiesModifierrecord componentadditionalAttributes- the value for theadditionalAttributesrecord component
-
-
Method Details
-
statsFor
Retrieves theToolStatsfor the given piece.- Parameters:
piece- the tool piece type- Returns:
- the stats
- Throws:
IllegalArgumentException- if no stats are defined for the piece
-
applyProperties
public net.minecraft.world.item.Item.Properties applyProperties(ToolPieceType piece, net.minecraft.world.item.Item.Properties base) Applies all property modifiers (set-level and piece-level) and builds the final attribute modifiers. Returns a newItem.Propertiesinstance. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
setName
Returns the value of thesetNamerecord component.- Returns:
- the value of the
setNamerecord component
-
tier
public net.minecraft.world.item.Tier tier()Returns the value of thetierrecord component.- Returns:
- the value of the
tierrecord component
-
statsByPiece
Returns the value of thestatsByPiecerecord component.- Returns:
- the value of the
statsByPiecerecord component
-
propertiesModifier
Returns the value of thepropertiesModifierrecord component.- Returns:
- the value of the
propertiesModifierrecord component
-
additionalAttributes
public Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes()Returns the value of theadditionalAttributesrecord component.- Returns:
- the value of the
additionalAttributesrecord component
-