moeru-ai/airi · error · ActionError

CRAFTING_FAILED

CRAFTING_FAILED

Error message

Failed to ensure crafting table

What it means

Thrown by ensureCraftingTable() as an ActionError with code CRAFTING_FAILED. The function first checks if the bot already has a crafting_table; if not it calls ensurePlanks(4) then craftRecipe('crafting_table', 1). If craftRecipe returns falsy (crafting did not succeed), it throws. This is a crafting-pipeline failure: the bot could not produce a crafting table from the prepared planks, usually because no crafting workstation was available, the recipe was unavailable, or inventory/space blocked the craft.

Source

Thrown at integrations/minecraft/src/skills/actions/ensure.ts:27

import { gatherWood } from './gather-wood'
import { getItemCount } from './inventory'

// Constants for crafting and gathering
const PLANKS_PER_LOG = 4
const STICKS_PER_PLANK = 2
const logger = useLogger()

export async function ensureCraftingTable(mineflayer: Mineflayer): Promise<boolean> {
  logger.log('Bot: Checking for a crafting table...')
  if (getItemCount(mineflayer, 'crafting_table') > 0)
    return true

  await ensurePlanks(mineflayer, 4)
  const result = await craftRecipe(mineflayer, 'crafting_table', 1)
  if (result)
    return true

  throw new ActionError('CRAFTING_FAILED', 'Failed to ensure crafting table')
}

// Helper function to ensure a specific amount of planks
export async function ensurePlanks(mineflayer: Mineflayer, neededAmount: number): Promise<boolean> {
  logger.log('Bot: Checking for planks...')

  let planksCount = getItemCount(mineflayer, 'planks')

  if (neededAmount <= planksCount) {
    logger.log('Bot: Have enough planks.')
    return true
  }

  const maxRetries = 3
  let retries = 0

  while (neededAmount > planksCount && retries < maxRetries) {
    retries++

View on GitHub (pinned to 27111382b4)

Solutions

  1. Place or locate a crafting table before calling ensureCraftingTable, or have one already in inventory (the function short-circuits when getItemCount > 0).
  2. Inspect the boolean returned by craftRecipe and its logs to find the sub-step that failed.
  3. Catch ActionError CRAFTING_FAILED and fall back to placing an existing table or requesting one.
  4. Verify the server's recipe registry recognises the crafting_table recipe for the bot's game version.

Example fix

// before
//   await ensureCraftingTable(mineflayer)  // throws CRAFTING_FAILED
//
// after
//   try {
//     await ensureCraftingTable(mineflayer)
//   } catch (e) {
//     if (e instanceof ActionError && e.code === 'CRAFTING_FAILED') {
//       await placeNearbyCraftingTable(mineflayer)  // fallback
//       return
//     }
//     throw e
//   }
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check inventory to avoid the craft path entirely:
// import { getItemCount } from './inventory'
// if (getItemCount(mineflayer, 'crafting_table') > 0) { /* already have one */ }
// else { /* ensure a workstation is available before crafting */ }

Type guard

function isCraftingError(e: unknown): e is { code: 'CRAFTING_FAILED', message: string } {
  return e instanceof Error && (e as any).name === 'ActionError' && (e as any).code === 'CRAFTING_FAILED'
}

Try / catch

// try {
//   await ensureCraftingTable(mineflayer)
// } catch (e) {
//   if (isCraftingError(e)) { await placeOrRequestTable(mineflayer); return }
//   throw e
// }

Prevention

When it happens

Trigger: craftRecipe returns false because there is no adjacent crafting table to craft against and the recipe requires one; the planks ensure step succeeded but the table recipe itself failed; recipe registry does not recognise 'crafting_table'; the bot is standing in a location where crafting is blocked.

Common situations: Bot in the open with no crafting table nearby and the craft call needs one; partial inventory preventing the 4-plank recipe; a modded server with a renamed recipe; ensurePlanks returned true but with the wrong plank type that the recipe rejects.

Related errors


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