moeru-ai/airi · error · ActionError

RESOURCE_MISSING

RESOURCE_MISSING

Error message

Don't have right tools to harvest ${block.name}

What it means

Thrown by collectBlock() as an ActionError with code RESOURCE_MISSING. In survival mode, the bot equips a tool via bot.tool.equipForBlock and checks block.canHarvest(heldItemType). If the held item cannot harvest the block, it tries ensurePickaxe() for ore/stone blocks, re-equips, and re-checks. If still unharvestable, it throws with the block name and a context payload. This is a hard resource gate: the bot lacks the required tool tier (e.g. needs diamond pickaxe for obsidian, has only iron).

Source

Thrown at integrations/minecraft/src/skills/actions/collect-block.ts:64

    }

    const block = blocks[0]

    try {
      // Equip appropriate tool
      if (mineflayer.bot.game.gameMode !== 'creative') {
        await mineflayer.bot.tool.equipForBlock(block)
        let itemId = mineflayer.bot.heldItem ? mineflayer.bot.heldItem.type : null
        if (!block.canHarvest(itemId)) {
          logger.log(`Don't have right tools to harvest ${block.name}.`)
          if (block.name.includes('ore') || block.name.includes('stone')) {
            await ensurePickaxe(mineflayer)
            // Re-equip after crafting/ensuring tool and re-check harvestability.
            await mineflayer.bot.tool.equipForBlock(block)
            itemId = mineflayer.bot.heldItem ? mineflayer.bot.heldItem.type : null
          }
          if (!block.canHarvest(itemId)) {
            throw new ActionError(
              'RESOURCE_MISSING',
              `Don't have right tools to harvest ${block.name}`,
              { blockType: block.name },
            )
          }
        }
      }

      // Implement vein mining
      const veinBlocks = findVeinBlocks(mineflayer, block, 100, range, 1)

      for (const veinBlock of veinBlocks) {
        if (collected >= num)
          break

        // Move to the block using pathfinder
        const goal = new pathfinder.goals.GoalGetToBlock(
          veinBlock.position.x,

View on GitHub (pinned to 27111382b4)

Solutions

  1. Switch the bot to creative mode if tool tier is not a concern.
  2. Ensure the bot has the required pickaxe tier before attempting (craft/equip a diamond pickaxe for obsidian-tier blocks).
  3. Catch ActionError with code RESOURCE_MISSING and skip the block or request the tool from a player.
  4. Pre-check block.canHarvest with the best available tool before calling collectBlock.

Example fix

// before
//   await collectBlock(mineflayer, 'diamond_ore', 1)
//   // throws RESOURCE_MISSING if bot lacks iron+ pickaxe
//
// after
//   try {
//     await collectBlock(mineflayer, 'diamond_ore', 1)
//   } catch (e) {
//     if (e instanceof ActionError && e.code === 'RESOURCE_MISSING') {
//       await chat({ message: `Need a better pickaxe for ${e.context?.blockType}` })
//       return
//     }
//     throw e
//   }
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check harvestability before collecting:
// import { ActionError } from '../../utils/errors'
// const block = getNearestBlocks(mineflayer, [blockType], range)[0]
// if (block && mineflayer.bot.game.gameMode !== 'creative') {
//   await mineflayer.bot.tool.equipForBlock(block)
//   const id = mineflayer.bot.heldItem ? mineflayer.bot.heldItem.type : null
//   if (!block.canHarvest(id)) { /* skip or request tool */ }
// }

Type guard

function isActionError(e: unknown): e is { code: string, context?: Record<string, unknown>, message: string } {
  return e instanceof Error && (e as any).name === 'ActionError' && typeof (e as any).code === 'string'
}

Try / catch

// try {
//   await collectBlock(mineflayer, 'diamond_ore', 1)
// } catch (e) {
//   if (isActionError(e) && e.code === 'RESOURCE_MISSING') {
//     await chat({ message: `Need a better tool for ${e.context?.blockType}` })
//     return
//   }
//   throw e
// }

Prevention

When it happens

Trigger: Trying to mine a high-tier block (diamond ore, obsidian, ancient debris) with a too-weak pickaxe; no pickaxe at all and ensurePickaxe could not craft one; the block requires a silk-touch/fortune tool the bot does not have; the bot is in survival with an empty hotbar.

Common situations: Early-game bot without iron/diamond tools; ensurePickaxe failed silently due to missing crafting ingredients; the bot's inventory lacks the tool tier the block demands; a recipe/crafting-table dependency was unavailable.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/0dfbc0f8f32182bd. Report an issue: GitHub.