inventoryDetails
Retrieve detailed information about inventory items in Minecraft to manage resources, identify items, and track contents during gameplay.
Instructions
Get detailed information about inventory items
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/inventoryManagement.ts:55-130 (handler)Handler function that fetches inventory items, equipped armor and held item, computes detailed info like durability and enchantments, and formats a textual response listing all details.async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const items = botState.bot.inventory.items() if (items.length === 0) { return createSuccessResponse('Inventory is empty.') } // Get equipped items const helmet = botState.bot.inventory.slots[5] const chestplate = botState.bot.inventory.slots[6] const leggings = botState.bot.inventory.slots[7] const boots = botState.bot.inventory.slots[8] const heldItem = botState.bot.heldItem // Create detailed item list with full info const itemsDetailed = items.map((item) => { return { name: item.name, displayName: item.displayName, count: item.count, type: item.type, durability: item.maxDurability ? `${item.durabilityUsed || 0}/${item.maxDurability}` : 'N/A', enchantments: item.enchants ? Object.keys(item.enchants).join(', ') : 'None', } }) // Create a formatted text output let response = 'Inventory Contents:\n\n' if (heldItem) { response += `Held Item: ${heldItem.displayName || heldItem.name} (x${ heldItem.count })\n` } else { response += 'Held Item: None\n' } response += '\nEquipped Armor:\n' response += `Helmet: ${ helmet ? helmet.displayName || helmet.name : 'None' }\n` response += `Chestplate: ${ chestplate ? chestplate.displayName || chestplate.name : 'None' }\n` response += `Leggings: ${ leggings ? leggings.displayName || leggings.name : 'None' }\n` response += `Boots: ${ boots ? boots.displayName || boots.name : 'None' }\n` response += '\nAll Items:\n' itemsDetailed.forEach((item, i) => { response += `${i + 1}. ${item.displayName} (x${item.count})` if (item.durability !== 'N/A') { response += ` - Durability: ${item.durability}` } if (item.enchantments !== 'None') { response += ` - Enchantments: ${item.enchantments}` } response += '\n' }) return createSuccessResponse(response) } catch (error) { return createErrorResponse(error) } }
- Input schema for the inventoryDetails tool, which is empty as no parameters are required.{},
- src/tools/inventoryManagement.ts:51-131 (registration)Registration of the inventoryDetails tool in the registerInventoryManagementTools function using server.tool.server.tool( 'inventoryDetails', 'Get detailed information about inventory items', {}, async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const items = botState.bot.inventory.items() if (items.length === 0) { return createSuccessResponse('Inventory is empty.') } // Get equipped items const helmet = botState.bot.inventory.slots[5] const chestplate = botState.bot.inventory.slots[6] const leggings = botState.bot.inventory.slots[7] const boots = botState.bot.inventory.slots[8] const heldItem = botState.bot.heldItem // Create detailed item list with full info const itemsDetailed = items.map((item) => { return { name: item.name, displayName: item.displayName, count: item.count, type: item.type, durability: item.maxDurability ? `${item.durabilityUsed || 0}/${item.maxDurability}` : 'N/A', enchantments: item.enchants ? Object.keys(item.enchants).join(', ') : 'None', } }) // Create a formatted text output let response = 'Inventory Contents:\n\n' if (heldItem) { response += `Held Item: ${heldItem.displayName || heldItem.name} (x${ heldItem.count })\n` } else { response += 'Held Item: None\n' } response += '\nEquipped Armor:\n' response += `Helmet: ${ helmet ? helmet.displayName || helmet.name : 'None' }\n` response += `Chestplate: ${ chestplate ? chestplate.displayName || chestplate.name : 'None' }\n` response += `Leggings: ${ leggings ? leggings.displayName || leggings.name : 'None' }\n` response += `Boots: ${ boots ? boots.displayName || boots.name : 'None' }\n` response += '\nAll Items:\n' itemsDetailed.forEach((item, i) => { response += `${i + 1}. ${item.displayName} (x${item.count})` if (item.durability !== 'N/A') { response += ` - Durability: ${item.durability}` } if (item.enchantments !== 'None') { response += ` - Enchantments: ${item.enchantments}` } response += '\n' }) return createSuccessResponse(response) } catch (error) { return createErrorResponse(error) } } )