Interface ItemPieceFactory<P,T extends net.minecraft.world.item.Item>

Type Parameters:
P - the type representing individual pieces (typically an enum)
T - the type of item created by this factory, must extend Item
All Known Implementing Classes:
ArmorFactory, ToolFactory

@Internal public interface ItemPieceFactory<P,T extends net.minecraft.world.item.Item>
Internal factory interface for creating individual item pieces within a set.

This interface provides the mechanism for creating specific item instances based on piece identifiers. Implementations are responsible for:

  • Mapping piece identifiers to their corresponding PieceType
  • Creating the actual item instances with appropriate configuration

Internal Use Only: This interface is part of the internal API and is not intended for direct implementation by mod developers. Breaking changes may occur without notice.

Implementations are typically used by ItemSet to lazily create individual pieces of armor sets, tool sets, or other related item collections.

Since:
2.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    create(P piece)
    Creates an item instance for the specified piece.
    getPieceType(P piece)
    Retrieves the piece type metadata for a given piece identifier.
  • Method Details

    • getPieceType

      PieceType getPieceType(P piece)
      Retrieves the piece type metadata for a given piece identifier.

      This method provides the naming and classification information needed for proper item registration and identification within a set.

      Parameters:
      piece - the piece identifier, never null
      Returns:
      the piece type metadata for the specified piece, never null
      Throws:
      NullPointerException - if piece is null
      IllegalArgumentException - if piece is not recognized
    • create

      T create(P piece)
      Creates an item instance for the specified piece.

      This method is responsible for constructing the actual item with all necessary properties, attributes, and configuration. The returned item should be fully configured and ready for registration and use.

      Parameters:
      piece - the piece identifier for which to create an item, never null
      Returns:
      a newly created item instance for the specified piece, never null
      Throws:
      NullPointerException - if piece is null
      IllegalStateException - if the item cannot be created due to invalid configuration or missing dependencies