moveTo
Teleport a Minecraft player to precise coordinates (x, y, z) using a remote server. Ideal for navigation, exploration, or repositioning within the game world.
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)Handler function that implements the moveTo tool logic: initializes Movements, sets GoalBlock to target coordinates, executes pathfinder.goto with promise resolution, error handling, and 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:42-45 (schema)Zod schema defining the input parameters for the moveTo tool: numeric x, y, z coordinates.x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), },
- src/tools/movement.ts:39-87 (registration)Registration of the moveTo tool via server.tool, including name, description, input schema, and inline handler function.'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) } } )