Interface ItemStack

All Superinterfaces:
HoverEventSource<HoverEvent.ShowItem>, TagReadable

public sealed interface ItemStack extends TagReadable, HoverEventSource<HoverEvent.ShowItem>
Represents an immutable item to be placed inside PlayerInventory, Inventory or even on the ground ItemEntity.

An item stack cannot be null, AIR should be used instead.

  • Field Details

    • AIR

      @NotNull static final @NotNull ItemStack AIR
      Constant AIR item. Should be used instead of 'null'.
  • Method Details

    • builder

      @Contract(value="_ -> new", pure=true) @NotNull static @NotNull ItemStack.Builder builder(@NotNull @NotNull Material material)
    • of

      @Contract(value="_ ,_ -> new", pure=true) @NotNull static @NotNull ItemStack of(@NotNull @NotNull Material material, int amount)
    • of

      @Contract(value="_ -> new", pure=true) @NotNull static @NotNull ItemStack of(@NotNull @NotNull Material material)
    • fromNBT

      @Contract(value="_, _, _ -> new", pure=true) @NotNull static @NotNull ItemStack fromNBT(@NotNull @NotNull Material material, @Nullable @Nullable org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound, int amount)
    • fromNBT

      @Contract(value="_, _ -> new", pure=true) @NotNull static @NotNull ItemStack fromNBT(@NotNull @NotNull Material material, @Nullable @Nullable org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound)
    • fromItemNBT

      @Experimental @NotNull static @NotNull ItemStack fromItemNBT(@NotNull @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound)
      Converts this item to an NBT tag containing the id (material), count (amount), and tag (meta).
      Parameters:
      nbtCompound - The nbt representation of the item
    • material

      @Contract(pure=true) @NotNull @NotNull Material material()
    • amount

      @Contract(pure=true) int amount()
    • meta

      @Contract(pure=true) @NotNull @NotNull ItemMeta meta()
    • meta

      @Contract(pure=true) @Experimental @NotNull <T extends ItemMetaView<?>> T meta(@NotNull @NotNull Class<T> metaClass)
    • with

      @Contract(value="_, -> new", pure=true) @NotNull @NotNull ItemStack with(@NotNull @NotNull Consumer<@NotNull ItemStack.Builder> consumer)
    • withMeta

      @Contract(value="_, _ -> new", pure=true) @Experimental @NotNull <V extends ItemMetaView.Builder, T extends ItemMetaView<V>> @NotNull ItemStack withMeta(@NotNull @NotNull Class<T> metaType, @NotNull @NotNull Consumer<V> consumer)
    • withMeta

      @Contract(value="_ -> new", pure=true) @NotNull @NotNull ItemStack withMeta(@NotNull @NotNull Consumer<@NotNull ItemMeta.Builder> consumer)
    • withMaterial

      @Contract(value="_, -> new", pure=true) @NotNull @NotNull ItemStack withMaterial(@NotNull @NotNull Material material)
    • withAmount

      @Contract(value="_, -> new", pure=true) @NotNull @NotNull ItemStack withAmount(int amount)
    • withAmount

      @Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withAmount(@NotNull @NotNull IntUnaryOperator intUnaryOperator)
    • consume

      @Experimental @Contract(value="_, -> new", pure=true) @NotNull @NotNull ItemStack consume(int amount)
    • getDisplayName

      @Contract(pure=true) @Nullable default @Nullable Component getDisplayName()
    • getLore

      @Contract(pure=true) @NotNull default @NotNull List<@NotNull Component> getLore()
    • withMeta

      @Experimental @Contract(value="_ -> new", pure=true) @NotNull @NotNull ItemStack withMeta(@NotNull @NotNull ItemMeta meta)
    • withDisplayName

      @Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withDisplayName(@Nullable @Nullable Component displayName)
    • withDisplayName

      @Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withDisplayName(@NotNull @NotNull UnaryOperator<@Nullable Component> componentUnaryOperator)
    • withLore

      @Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withLore(@NotNull @NotNull List<? extends Component> lore)
    • withLore

      @Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withLore(@NotNull @NotNull UnaryOperator<@NotNull List<@NotNull Component>> loreUnaryOperator)
    • isAir

      @Contract(pure=true) default boolean isAir()
    • isSimilar

      @Contract(pure=true) boolean isSimilar(@NotNull @NotNull ItemStack itemStack)
    • withTag

      @Contract(value="_, _ -> new", pure=true) @NotNull default <T> @NotNull ItemStack withTag(@NotNull @NotNull Tag<T> tag, @Nullable T value)
    • getTag

      default <T> @UnknownNullability T getTag(@NotNull @NotNull Tag<T> tag)
      Description copied from interface: TagReadable
      Reads the specified tag.
      Specified by:
      getTag in interface TagReadable
      Type Parameters:
      T - the tag type
      Parameters:
      tag - the tag to read
      Returns:
      the read tag, null if not present
    • asHoverEvent

      @NotNull default @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull @NotNull UnaryOperator<HoverEvent.ShowItem> op)
      Specified by:
      asHoverEvent in interface HoverEventSource<HoverEvent.ShowItem>
    • toItemNBT

      @Experimental @NotNull @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound toItemNBT()
      Converts this item to an NBT tag containing the id (material), count (amount), and tag (meta)
      Returns:
      The nbt representation of the item