moveTo
Teleport a player to specified coordinates in Minecraft, enabling precise navigation and location management for remote server control.
Instructions
Move the player to a specific location
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate | |
| y | Yes | Y coordinate | |
| z | Yes | Z coordinate |
Implementation Reference
- src/tools/movement.ts:46-86 (handler)The handler function for the 'moveTo' tool. It configures the bot's pathfinder movements and sets a GoalBlock to the target coordinates, handling success, errors, and a 60-second timeout.async ({ x, y, z }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Set pathfinder Movements const movements = new Movements(botState.bot) botState.bot.pathfinder.setMovements(movements) // Set target position const goal = new goals.GoalBlock(x, y, z) return new Promise<ToolResponse>((resolve) => { // Start movement botState .bot!.pathfinder.goto(goal) .then(() => { resolve( createSuccessResponse( `Successfully moved to X=${x}, Y=${y}, Z=${z}` ) ) }) .catch((err) => { resolve(createErrorResponse(err)) }) // Timeout handling (if still moving after 1 minute) setTimeout(() => { resolve( createSuccessResponse( 'Movement is taking longer than expected. Still trying to reach the destination...' ) ) }, 60000) }) } catch (error) { return createErrorResponse(error) } }
- src/tools/movement.ts:41-45 (schema)Zod schema defining the input parameters for the moveTo tool: x, y, z coordinates as numbers.{ x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), },
- src/tools/movement.ts:38-87 (registration)Direct registration of the 'moveTo' tool via server.tool call within the registerMovementTools function.server.tool( 'moveTo', 'Move the player to a specific location', { x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), }, async ({ x, y, z }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Set pathfinder Movements const movements = new Movements(botState.bot) botState.bot.pathfinder.setMovements(movements) // Set target position const goal = new goals.GoalBlock(x, y, z) return new Promise<ToolResponse>((resolve) => { // Start movement botState .bot!.pathfinder.goto(goal) .then(() => { resolve( createSuccessResponse( `Successfully moved to X=${x}, Y=${y}, Z=${z}` ) ) }) .catch((err) => { resolve(createErrorResponse(err)) }) // Timeout handling (if still moving after 1 minute) setTimeout(() => { resolve( createSuccessResponse( 'Movement is taking longer than expected. Still trying to reach the destination...' ) ) }, 60000) }) } catch (error) { return createErrorResponse(error) } } )