Class EnchantIDProvider

java.lang.Object
com.kamikazejam.kamicommon.nms.provider.Provider<AbstractEnchantID>
com.kamikazejam.kamicommon.nms.provider.EnchantIDProvider

public class EnchantIDProvider extends Provider<AbstractEnchantID>
Provider for version-specific enchantment ID implementations.

This provider selects the appropriate AbstractEnchantID implementation based on the current Minecraft version, handling the transition from legacy enchantment IDs to namespaced identifiers that occurred in Minecraft 1.13.

The provider addresses the "flattening" update's impact on enchantments:

  • Pre-1.13: Numeric enchantment IDs and legacy name formats
  • 1.13+: Namespaced enchantment identifiers (e.g., "minecraft:sharpness")

This enables consistent enchantment identification across versions while providing access to modern namespaced identifiers for compatibility with newer systems and external tools that expect standardized enchantment names.

See Also:
  • Constructor Details

    • EnchantIDProvider

      public EnchantIDProvider()
  • Method Details

    • provide

      @NotNull protected @NotNull AbstractEnchantID provide(int ver)
      Creates the appropriate implementation for the specified NMS version.

      This method must be implemented by subclasses to provide version-specific logic for creating the appropriate implementation. The method receives a formatted NMS integer that can be compared against known version thresholds to determine which implementation to create.

      Use the Provider.f(String) helper method to convert Minecraft version strings to formatted integers for comparison.

      Selects the enchantment ID implementation based on the 1.13 flattening update. Pre-1.13 versions use legacy numeric IDs, while 1.13+ versions use namespaced identifiers for enchantments.

      Specified by:
      provide in class Provider<AbstractEnchantID>
      Parameters:
      ver - the formatted NMS version integer
      Returns:
      the version-appropriate AbstractEnchantID implementation