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 set
tier - the material tier (durability, mining level)
statsByPiece - a map from piece type to its ToolStats
propertiesModifier - a global modifier for item properties
additionalAttributes - 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 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 a ToolContext record class.
      Parameters:
      setName - the value for the setName record component
      tier - the value for the tier record component
      statsByPiece - the value for the statsByPiece record component
      propertiesModifier - the value for the propertiesModifier record component
      additionalAttributes - the value for the additionalAttributes record component
  • Method Details

    • statsFor

      public ToolStats statsFor(ToolPieceType piece)
      Retrieves the ToolStats for 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 new Item.Properties instance.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • setName

      public String setName()
      Returns the value of the setName record component.
      Returns:
      the value of the setName record component
    • tier

      public net.minecraft.world.item.Tier tier()
      Returns the value of the tier record component.
      Returns:
      the value of the tier record component
    • statsByPiece

      public Map<ToolPieceType,ToolStats> statsByPiece()
      Returns the value of the statsByPiece record component.
      Returns:
      the value of the statsByPiece record component
    • propertiesModifier

      public UnaryOperator<net.minecraft.world.item.Item.Properties> propertiesModifier()
      Returns the value of the propertiesModifier record component.
      Returns:
      the value of the propertiesModifier record component
    • additionalAttributes

      public Consumer<net.minecraft.world.item.component.ItemAttributeModifiers.Builder> additionalAttributes()
      Returns the value of the additionalAttributes record component.
      Returns:
      the value of the additionalAttributes record component