Skip to main content
Glama

useOnEntity

Interact with a specific Minecraft entity by using the held item, enabling precise control for inventory management and gameplay actions through remote server commands.

Instructions

Use held item on a specific entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityIdYesID of the entity to use item on

Implementation Reference

  • The handler function that implements the core logic of the 'useOnEntity' tool. It verifies bot connection, locates the entity by ID, performs bot.useOn(entity), determines the held item, and returns a formatted success response or error.
    async ({ entityId }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the entity by ID const entity = botState.bot.entities[entityId] if (!entity) { return createSuccessResponse(`Entity with ID ${entityId} not found.`) } // Use current item on the entity await botState.bot.useOn(entity) const heldItem = botState.bot.heldItem ? botState.bot.heldItem.name : 'hand' return createSuccessResponse( `Used ${heldItem} on entity: ${ entity.name || entity.username || 'Unknown entity' } (ID: ${entityId})` ) } catch (error) { return createErrorResponse(error) } } )
  • Zod input schema defining the required 'entityId' parameter as a number for the 'useOnEntity' tool.
    { entityId: z.number().describe('ID of the entity to use item on'), },
  • Direct registration of the 'useOnEntity' tool using server.tool(), including name, description, schema, and handler function.
    server.tool( 'useOnEntity', 'Use held item on a specific entity', { entityId: z.number().describe('ID of the entity to use item on'), }, async ({ entityId }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the entity by ID const entity = botState.bot.entities[entityId] if (!entity) { return createSuccessResponse(`Entity with ID ${entityId} not found.`) } // Use current item on the entity await botState.bot.useOn(entity) const heldItem = botState.bot.heldItem ? botState.bot.heldItem.name : 'hand' return createSuccessResponse( `Used ${heldItem} on entity: ${ entity.name || entity.username || 'Unknown entity' } (ID: ${entityId})` ) } catch (error) { return createErrorResponse(error) } } )
  • Invocation of registerEntityInteractionTools() within registerAllTools(), which registers the 'useOnEntity' tool among entity interaction tools.
    registerEntityInteractionTools()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nacal/mcp-minecraft-remote'

If you have feedback or need assistance with the MCP directory API, please join our Discord server