Interface AbstractItemNbt

All Known Subinterfaces:
AbstractItemTextPre_1_17

public interface AbstractItemNbt
Reads the two pieces of item NBT an Adventure show_item hover is built from.

Adventure holds an item hover as an id, a count and a tag compound, and reassembles the wire form from those three. Servers from 1.18.2 onward hand that over through their own ItemStack.asHoverEvent(); below it, the values have to be read from NMS, which is what this interface is for.

Implemented for every server version below 1.18.2. From 1.8 to 1.16.5 the implementation is the one AbstractItemTextPre_1_17 already carried, which is why that interface extends this one; 1.17 and 1.18.1 have their own.

  • Method Summary

    Modifier and Type
    Method
    Description
    The item's namespaced id, as the server's own item registry writes it.
    The item's tag compound as an SNBT string, or null when it has none.
  • Method Details

    • getItemId

      String getItemId(ItemStack item)
      The item's namespaced id, as the server's own item registry writes it.
      Parameters:
      item - the ItemStack to read
      Returns:
      the namespaced id, for example minecraft:wool, or an empty string for air
    • getNbtTag

      String getNbtTag(ItemStack item)
      The item's tag compound as an SNBT string, or null when it has none.

      This is the inner compound holding the display name, lore and enchantments. It is not the whole item NBT, which also carries id, Count and, below 1.13, Damage. Handing the whole item over instead nests it under a second tag key and produces a hover that renders as the plain item with no name and no lore.

      Parameters:
      item - the ItemStack to read
      Returns:
      the tag compound as SNBT, or null when the item carries no tag