digBlock
Remove a block at specific coordinates in Minecraft by specifying X, Y, and Z values, enabling precise block manipulation for remote server gameplay.
Instructions
Dig a block at the specified coordinates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate | |
| y | Yes | Y coordinate | |
| z | Yes | Z coordinate |
Implementation Reference
- src/tools/blocks.ts:22-65 (handler)The main handler function for the digBlock tool. It checks connection, fetches the block at coordinates, digs it using bot.dig(), handles promises, errors, and includes a 30-second timeout.async ({ x, y, z }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Get block at specified coordinates const block = botState.bot.blockAt(new Vec3(x, y, z)) if (!block || block.name === 'air') { return createSuccessResponse( 'No block found at the specified coordinates.' ) } return new Promise<ToolResponse>((resolve) => { // Dig the block botState .bot!.dig(block) .then(() => { resolve( createSuccessResponse( `Successfully dug ${block.name} at X=${x}, Y=${y}, Z=${z}` ) ) }) .catch((err) => { resolve(createErrorResponse(err)) }) // Timeout handling (if still digging after 30 seconds) setTimeout(() => { resolve( createSuccessResponse( 'Digging is taking longer than expected. Still trying...' ) ) }, 30000) }) } catch (error) { return createErrorResponse(error) } } )
- src/tools/blocks.ts:17-21 (schema)Zod schema for input parameters: 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/blocks.ts:14-66 (registration)The server.tool call that registers the digBlock tool with MCP server, including name, description, schema, and handler.server.tool( 'digBlock', 'Dig a block at the specified coordinates', { 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 { // Get block at specified coordinates const block = botState.bot.blockAt(new Vec3(x, y, z)) if (!block || block.name === 'air') { return createSuccessResponse( 'No block found at the specified coordinates.' ) } return new Promise<ToolResponse>((resolve) => { // Dig the block botState .bot!.dig(block) .then(() => { resolve( createSuccessResponse( `Successfully dug ${block.name} at X=${x}, Y=${y}, Z=${z}` ) ) }) .catch((err) => { resolve(createErrorResponse(err)) }) // Timeout handling (if still digging after 30 seconds) setTimeout(() => { resolve( createSuccessResponse( 'Digging is taking longer than expected. Still trying...' ) ) }, 30000) }) } catch (error) { return createErrorResponse(error) } } )
- src/tools/index.ts:25-25 (registration)Call to registerBlockTools() within registerAllTools(), which triggers the registration of digBlock and placeBlock tools.registerBlockTools()