Skip to main content
Glama

dig-block

Remove blocks at specific coordinates in Minecraft to clear terrain, create openings, or gather resources for building and exploration.

Instructions

Dig a block at the specified position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate
zYesZ coordinate

Implementation Reference

  • Handler function for the 'dig-block' tool. It retrieves the bot, checks for a block at the given coordinates, navigates if necessary, digs the block, and returns a success message.
    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})`);
    }
  • Zod input schema for 'dig-block' tool defining required numeric parameters x, y, z coordinates.
    {
      x: z.number().describe("X coordinate"),
      y: z.number().describe("Y coordinate"),
      z: z.number().describe("Z coordinate"),
    },
  • Registration of the 'dig-block' tool using ToolFactory.registerTool, including name, description, schema, and inline handler 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})`);
      }
    );

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/yuniko-software/minecraft-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server