digBlock
Remove blocks at specific coordinates in Minecraft to clear terrain, create structures, or mine resources using coordinate-based targeting.
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-64 (handler)The main handler logic for the digBlock tool. It checks connection, retrieves the block at (x,y,z), digs it if present, 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 input schema defining required number parameters for x, y, z coordinates.{ x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), },
- src/tools/blocks.ts:14-65 (registration)Registers the digBlock tool with server.tool, including name, description, input schema, and handler function.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)Calls registerBlockTools() which in turn registers the digBlock tool among others.registerBlockTools()