Skip to main content
Glama

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
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate
zYesZ coordinate

Implementation Reference

  • 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)
      }
    }
  • 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'),
    },
  • 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)
        }
      }
    )

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