PlayerInventory

Represents a player's inventory.

Functions

Link copied to clipboard
abstract fun addItem(item: ItemStack)

Puts the specified item in the first available empty slot in this inventory, or does nothing if the inventory is full.

Link copied to clipboard
abstract fun clear()

Clears this inventory.

Link copied to clipboard
open fun forEach(p0: Consumer<in ItemStack>)
Link copied to clipboard
abstract fun getArmor(slot: ArmorSlot): ItemStack

Gets the armour item in the given slot.

Link copied to clipboard
abstract fun getHeldItem(hand: Hand): ItemStack

Gets the item the player is holding in the given hand.

Link copied to clipboard
abstract fun getItem(index: Int): ItemStack

Retrieve an item from this inventory at the specified index.

Link copied to clipboard
abstract fun hasItem(item: ItemStack): Boolean

If this inventory contains the specified item.

Link copied to clipboard
abstract operator fun iterator(): Iterator<ItemStack>
Link copied to clipboard
abstract fun removeItem(item: ItemStack)

Removes the specified item from the array, or does nothing if there isn't an element that matches this item.

Link copied to clipboard
abstract fun setArmor(slot: ArmorSlot, item: ItemStack)

Sets the armour item in the given slot to the give item.

Link copied to clipboard
abstract fun setHeldItem(hand: Hand, item: ItemStack)

Sets the item the player is holding in the given hand to the given item.

Link copied to clipboard
abstract fun setItem(index: Int, item: ItemStack)

Sets the item at the given index to the given item.

Link copied to clipboard

Properties

Link copied to clipboard
abstract val armor: List<ItemStack>

The array of armor pieces in this inventory.

Link copied to clipboard
abstract var boots: ItemStack

The boots this player is currently wearing.

Link copied to clipboard
abstract var chestplate: ItemStack

The chestplate this player is currently wearing.

Link copied to clipboard
abstract val crafting: List<ItemStack>

The array of crafting slots in this inventory, where the first 4 elements of this array are the input, and the last slot is the output.

Link copied to clipboard
abstract val heldSlot: Int

The slot of the currently held item.

Link copied to clipboard
abstract var helmet: ItemStack

The helmet this player is currently wearing.

Link copied to clipboard
abstract val hotbar: List<ItemStack>

The hotbar area. This has 9 slots, and covers from slots 0 to 8.

Link copied to clipboard
abstract val items: List<ItemStack>

The items in this inventory.

Link copied to clipboard
abstract var leggings: ItemStack

The leggings this player is currently wearing.

Link copied to clipboard
abstract val main: List<ItemStack>

The main inventory area, excluding the hotbar area. This has 27 slots, and covers from slots 9 to 35.

Link copied to clipboard
abstract val mainHand: ItemStack

The item that this player is currently holding in their main hand.

Link copied to clipboard
abstract val offHand: ItemStack

The item that this player is currently holding in their offhand.

Link copied to clipboard
abstract val owner: Player

The owner of this player inventory.

Link copied to clipboard
abstract val size: Int

The size of this inventory.

Link copied to clipboard
abstract val type: InventoryType

The type of this inventory.