getPosition
Retrieve the player's current coordinates in the Minecraft world to enable navigation, building, and location tracking.
Instructions
Get the current position of the player in the Minecraft world
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/movement.ts:19-34 (handler)The handler function for the getPosition tool. It checks if the bot is connected, retrieves the bot's entity position, formats it into a string, and returns a success response.async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const position = botState.bot.entity.position return createSuccessResponse( `Current position: X=${position.x.toFixed(2)}, Y=${position.y.toFixed( 2 )}, Z=${position.z.toFixed(2)}` ) } catch (error) { return createErrorResponse(error) } }
- src/tools/movement.ts:15-35 (registration)Registers the getPosition tool using server.tool method, with description, empty input schema, and inline handler function.server.tool( 'getPosition', 'Get the current position of the player in the Minecraft world', {}, async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const position = botState.bot.entity.position return createSuccessResponse( `Current position: X=${position.x.toFixed(2)}, Y=${position.y.toFixed( 2 )}, Z=${position.z.toFixed(2)}` ) } catch (error) { return createErrorResponse(error) } } )