dig-block
Remove a Minecraft block at specified coordinates (x, y, z) using the MCP server, enabling real-time game interaction and structure modification.
Instructions
Dig a block at the specified position
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate | |
| y | Yes | Y coordinate | |
| z | Yes | Z coordinate |
Implementation Reference
- src/tools/block-tools.ts:86-102 (handler)The handler function executes the digging logic: checks for block at position, navigates if needed using pathfinder, then calls bot.dig(block).async ({ x, y, z }) => { const bot = getBot(); const blockPos = new Vec3(x, y, z); const block = bot.blockAt(blockPos); if (!block || block.name === 'air') { return factory.createResponse(`No block found at position (${x}, ${y}, ${z})`); } if (!bot.canDigBlock(block) || !bot.canSeeBlock(block)) { const goal = new goals.GoalNear(x, y, z, 2); await bot.pathfinder.goto(goal); } await bot.dig(block); return factory.createResponse(`Dug ${block.name} at (${x}, ${y}, ${z})`); }
- src/tools/block-tools.ts:81-85 (schema)Zod schema defining required numeric inputs 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/block-tools.ts:78-103 (registration)The factory.registerTool call registers the "dig-block" tool with its schema and handler within the registerBlockTools function.factory.registerTool( "dig-block", "Dig a block at the specified position", { x: z.number().describe("X coordinate"), y: z.number().describe("Y coordinate"), z: z.number().describe("Z coordinate"), }, async ({ x, y, z }) => { const bot = getBot(); const blockPos = new Vec3(x, y, z); const block = bot.blockAt(blockPos); if (!block || block.name === 'air') { return factory.createResponse(`No block found at position (${x}, ${y}, ${z})`); } if (!bot.canDigBlock(block) || !bot.canSeeBlock(block)) { const goal = new goals.GoalNear(x, y, z, 2); await bot.pathfinder.goto(goal); } await bot.dig(block); return factory.createResponse(`Dug ${block.name} at (${x}, ${y}, ${z})`); } );