Class HoverEvent.ShowItem

java.lang.Object
net.kyori.adventure.text.event.HoverEvent.ShowItem
Enclosing class:
HoverEvent<V>

public static final class HoverEvent.ShowItem extends Object
The value of a show_item hover event.
Since:
4.0.0
  • Method Details

    • showItem

      public static HoverEvent.ShowItem showItem(Key item, @Range(from=0L,to=2147483647L) int count)
      Creates.
      Parameters:
      item - the item
      count - the count
      Returns:
      a ShowItem
      Since:
      4.14.0
    • showItem

      public static HoverEvent.ShowItem showItem(Keyed item, @Range(from=0L,to=2147483647L) int count)
      Creates.
      Parameters:
      item - the item
      count - the count
      Returns:
      a ShowItem
      Since:
      4.14.0
    • showItem

      @Obsolete public static HoverEvent.ShowItem showItem(Key item, @Range(from=0L,to=2147483647L) int count, @Nullable BinaryTagHolder nbt)
      Creates.
      Parameters:
      item - the item
      count - the count
      nbt - the nbt
      Returns:
      a ShowItem
      Since:
      4.14.0
      Obsolete since Minecraft
      since 1.20.5 and replaced with data components
    • showItem

      @Obsolete public static HoverEvent.ShowItem showItem(Keyed item, @Range(from=0L,to=2147483647L) int count, @Nullable BinaryTagHolder nbt)
      Creates.
      Parameters:
      item - the item
      count - the count
      nbt - the nbt
      Returns:
      a ShowItem
      Since:
      4.14.0
      Obsolete
      since 1.20.5 and replaced with data components
    • showItem

      public static HoverEvent.ShowItem showItem(Keyed item, @Range(from=0L,to=2147483647L) int count, Map<Key, ? extends DataComponentValue> dataComponents)
      Creates.
      Parameters:
      item - the item
      count - the count
      dataComponents - the data components
      Returns:
      a ShowItem
      Since:
      4.17.0
      Since Minecraft:
      1.20.5
    • item

      public Key item()
      Gets the item.
      Returns:
      the item
      Since:
      4.0.0
    • item

      public HoverEvent.ShowItem item(Key item)
      Sets the item.
      Parameters:
      item - the item
      Returns:
      a ShowItem
      Since:
      4.0.0
    • count

      public @Range(from=0L,to=2147483647L) int count()
      Gets the count.
      Returns:
      the count
      Since:
      4.0.0
    • count

      public HoverEvent.ShowItem count(@Range(from=0L,to=2147483647L) int count)
      Sets the count.
      Parameters:
      count - the count
      Returns:
      a ShowItem
      Since:
      4.0.0
    • nbt

      @Obsolete public @Nullable BinaryTagHolder nbt()
      Gets the nbt.

      If there are data components on this item, it will never have NBT data.

      Returns:
      the nbt
      Since:
      4.0.0
      Obsolete since Minecraft
      since 1.20.5 and replaced with data components
    • nbt

      @Obsolete public HoverEvent.ShowItem nbt(@Nullable BinaryTagHolder nbt)
      Sets the nbt.

      This will clear any modern data components set on the item.

      Parameters:
      nbt - the nbt
      Returns:
      a ShowItem
      Since:
      4.0.0
      Obsolete since Minecraft
      1.20.5 and replaced with data components
    • dataComponents

      public Map<Key, DataComponentValue> dataComponents()
      Get the data components used for this item.

      If there is NBT data on this item, it will never have any data components set.

      Returns:
      an unmodifiable map of data components
      Since:
      4.17.0
      Since Minecraft:
      1.20.5
    • dataComponents

      public HoverEvent.ShowItem dataComponents(Map<Key, DataComponentValue> holder)
      Set the data components used on this item.

      This will clear any legacy NBT-format data on the item.

      Parameters:
      holder - the new data components to set
      Returns:
      a show item data object that has the provided components
      Since:
      4.17.0
      Since Minecraft:
      1.20.5
    • dataComponentsAs

      public <V extends DataComponentValue> Map<Key,V> dataComponentsAs(Class<V> targetType)
      Return an unmodifiable map of data components coerced to the target type.

      If there is no converter registered with the DataComponentValueConverterRegistry for the conversion of a value, a IllegalArgumentException will be thrown.

      Type Parameters:
      V - the new data component value type
      Parameters:
      targetType - the expected target type
      Returns:
      the unmodifiable map
      Since:
      4.17.0
      Since Minecraft:
      1.20.5
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object