checkInventory
View player inventory contents in Minecraft to track items, manage resources, and plan actions during gameplay.
Instructions
Check the items in the player inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/inventory.ts:15-34 (handler)The async handler function that executes the checkInventory tool logic: checks if bot is connected, retrieves inventory items, formats them into a string, and returns a success response or appropriate error.async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const items = botState.bot.inventory.items() if (items.length === 0) { return createSuccessResponse('Inventory is empty.') } const itemList = items .map((item) => `${item.name} x${item.count}`) .join(', ') return createSuccessResponse(`Inventory contains: ${itemList}`) } catch (error) { return createErrorResponse(error) } }
- src/tools/inventory.ts:11-35 (registration)The server.tool call that registers the 'checkInventory' tool with its description, empty schema ({}), and inline handler function.server.tool( 'checkInventory', 'Check the items in the player inventory', {}, async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const items = botState.bot.inventory.items() if (items.length === 0) { return createSuccessResponse('Inventory is empty.') } const itemList = items .map((item) => `${item.name} x${item.count}`) .join(', ') return createSuccessResponse(`Inventory contains: ${itemList}`) } catch (error) { return createErrorResponse(error) } } )