Class ItemNbtProvider

java.lang.Object
com.kamikazejam.kamicommon.nms.provider.Provider<AbstractItemNbt>
com.kamikazejam.kamicommon.nms.provider.ItemNbtProvider

public class ItemNbtProvider extends Provider<AbstractItemNbt>
Provider for the item NBT an Adventure show_item hover is built from.

Covers 1.8 through 1.18.1 and throws above it. From 1.18.2 a server has its own Adventure and hands the hover over through ItemStack.asHoverEvent(), so nothing on those versions asks for this.

Below 1.17 the implementation is the one AbstractItemTextPre_1_17 already carries, so those branches resolve the same adapter the item text provider does. 1.17 and 1.18.1 are separate modules because their mappings differ.

This lives in :api rather than :core for the same reason ItemTextProviderPre_1_17 does: it is resolved from inside the nested Adventure jar, whose classloader can see :api by parent-first delegation and cannot see :core.

See Also:
  • Constructor Details

    • ItemNbtProvider

      public ItemNbtProvider()
  • Method Details

    • provide

      @NotNull protected @NotNull AbstractItemNbt 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.

      Specified by:
      provide in class Provider<AbstractItemNbt>
      Parameters:
      ver - the formatted NMS version integer
      Returns:
      the version-appropriate AbstractItemNbt implementation
      Throws:
      IllegalArgumentException - if the version is below 1.8 or 1.18.2 and above