ItemStack

A stack of items in an inventory.

Types

Link copied to clipboard

For building new ItemStacks.

Link copied to clipboard
object Companion
Link copied to clipboard
@ApiStatus.Internal
interface Factory

Functions

Link copied to clipboard
@NotNull
open fun asHoverEvent(): @NotNull HoverEvent<HoverEvent.ShowItem>
@NotNull
abstract fun asHoverEvent(@NotNull op: @NotNull UnaryOperator<HoverEvent.ShowItem>): @NotNull HoverEvent<HoverEvent.ShowItem>
Link copied to clipboard
@Contract(value = "_ -> new", pure = true)
open fun grow(amount: Int): ItemStack

Grows the amount of this item stack by the given amount and returns the resulting item stack.

Link copied to clipboard
abstract fun <I : ItemMeta> meta(type: Class<I>): I?

Gets the metadata for this item stack as the given type I, or returns null if the metadata could not be casted to the given type.

Link copied to clipboard
inline fun <I : ItemMeta> ItemStack.meta(): I?

Gets the metadata for this item stack as the given type I, or returns null if the metadata could not be casted to the given type I.

Link copied to clipboard
@Contract(value = "_ -> new", pure = true)
open fun shrink(amount: Int): ItemStack

Shrinks the amount of this item stack by the given amount and returns the resulting item stack.

Link copied to clipboard
@Contract(value = "-> new", pure = true)
@NotNull
abstract fun toBuilder(): @NotNull ItemStack.Builder
Link copied to clipboard
@Contract(value = "_ -> new", pure = true)
abstract fun withAmount(amount: Int): ItemStack

Creates a new item stack with the given amount.

Link copied to clipboard
@Contract(value = "_ -> new", pure = true)
open fun withMeta(builder: Consumer<ItemMeta.Builder>): ItemStack

Creates a new item stack with meta retrieved applying the given builder to a new item metadata builder.

@Contract(value = "_ -> new", pure = true)
abstract fun withMeta(meta: ItemMeta): ItemStack

Creates a new item stack with the given meta.

@Contract(value = "_, _ -> new", pure = true)
open fun <B : ItemMetaBuilder<B, P>, P : ItemMetaBuilder.Provider<B>, ItemMeta> withMeta(type: Class<P>, builder: Consumer<B>): ItemStack

Creates a new item stack with meta retrieved applying the given builder to a new meta builder created with the given type.

Link copied to clipboard
@Contract(value = "_ -> new", pure = true)
@JvmName(name = "withMetaGeneric")
inline fun <B : IMB<B, P>, P : IMP<B>, ItemMeta> ItemStack.withMeta(builder: B.() -> Unit): ItemStack

Creates a new item stack with meta retrieved applying the given builder to a new meta builder created with the given type P.

@Contract(value = "_ -> new", pure = true)
inline fun ItemStack.withMeta(builder: ItemMeta.Builder.() -> Unit): ItemStack

Creates a new item stack with meta retrieved applying the given builder to a new item metadata builder.

Link copied to clipboard
@Contract(value = "_ -> new", pure = true)
abstract fun withType(type: ItemType): ItemStack

Creates a new item stack with the given type.

Properties

Link copied to clipboard
@get:JvmName(name = "amount")
abstract val amount: Int

The amount of items in this stack.

Link copied to clipboard
@get:JvmName(name = "meta")
abstract val meta: ItemMeta

The metadata for this item stack.

Link copied to clipboard
@get:JvmName(name = "type")
abstract val type: ItemType

The type of item in this stack.