checkInventory
Retrieve and view the items in a player's inventory directly within Minecraft. Simplify inventory management by accessing item details through remote server commands.
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 implements the core logic of the 'checkInventory' tool. It verifies bot connection, fetches inventory items, formats the item list (name x count), and returns a formatted success response or handles errors appropriately.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 registration of the 'checkInventory' tool via server.tool(), including the tool name, description, empty input 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) } } )