createItem

open fun createItem(itemId: Key): ItemStack?(source)

Creates a new stack with a single item with itemId.


open fun createItem(itemId: Key, amount: Int): ItemStack?(source)

Creates a new stack of the item with itemId and the given amount.


open fun createItem(itemId: Key, amount: Int, player: Player?): ItemStack?(source)

Creates a new stack of the item with itemId and the given amount for the player.


abstract fun createItem(itemId: Key, amount: Int = 1, player: Player? = null, payload: String? = null): ItemStack?(source)

Creates a new stack of the item with itemId. The caller owns the returned stack.

Return

the stack, or null if the ID is unknown or the payload is invalid.

Parameters

amount

Amount of items. It is kept within 1 and the maximum stack size of the item.

player

The player the item is created for, or null if there is no such player. Some items depend on the player, like items scaled to the player's level.

payload

Additional configuration of the item in the format of its provider. A blank payload is the same as null. For example, minecraft takes item components like [damage=10]. Providers taking no payload ignore it. If the payload is invalid, the item is not created and a warning is logged.