Overview
Minestom provides a comprehensive inventory system for managing items in containers, player inventories, and custom GUIs.Inventory
Represents an inventory that can be viewed by multiple players.Creating Inventories
Constructor
Creates a new inventory
Item Management
Sets an ItemStack at the specified slotAutomatically sends updates to all viewers
Gets the ItemStack at the specified slot
Adds an ItemStack to the inventoryReturns
true if the item was successfully addedTakes an ItemStack from the inventory
Replaces an ItemStack using an operator
Clears all items from the inventory and updates viewers
Gets a copy of all items in the inventory
Copies items from an array into this inventory
Viewers
Adds a viewer (does NOT open the inventory)Use
player.openInventory(inventory) to actually open itRemoves a viewer (does NOT close the inventory)Use
player.closeInventory() to close itGets all players currently viewing this inventory
Refreshes the inventory for all viewers
Properties
Gets the inventory type
Gets the inventory title
Changes the inventory titleRe-opens the inventory for all viewers
Gets the total size of the inventory (number of slots)
Gets the window ID used by the client to identify this inventory
Click Handling
Sets a custom click processor for handling inventory clicks
Adds a click condition/handler
PlayerInventory
Represents a player’s inventory (extends AbstractInventory).Accessing Player Inventory
Equipment Methods
Gets equipment in a specific slot
Sets equipment in a specific slot
Cursor Item
Gets the item in the player’s cursor (what they’re dragging)
Sets the cursor item
Constants
Total inventory size (46 slots)
Main inventory size excluding armor/offhand (36 slots)
InventoryType
Enum representing different inventory types.Available Types
9-slot chest (1 row)
18-slot chest (2 rows)
27-slot chest (3 rows)
36-slot chest (4 rows)
45-slot chest (5 rows)
54-slot chest (6 rows)
5-slot hopper
3-slot furnace
10-slot crafting table
3-slot anvil
2-slot enchanting table
5-slot brewing stand
1-slot beacon
27-slot shulker box
BLAST_FURNACE, SMOKER, LOOM, GRINDSTONE, SMITHING, CARTOGRAPHY, STONE_CUTTER, etc.
Methods
Gets the number of slots in this inventory type
Gets the protocol window type ID
Usage Examples
Custom GUI Menu
Paginated Inventory
Event Listening
Use
player.openInventory(inventory) to open and player.closeInventory() to close inventories. Direct viewer management with addViewer/removeViewer does not send open/close packets.