{"record":{"id":"4490eed806b7ecbf","repo":"moeru-ai/airi","slug":"resource-missing-4490ee","errorCode":"RESOURCE_MISSING","errorMessage":"Could not gather wood","messagePattern":"Could not gather wood","errorType":"error_code","errorClass":"ActionError","httpStatus":null,"severity":"error","filePath":"integrations/minecraft/src/skills/actions/ensure.ts","lineNumber":60,"sourceCode":"  let retries = 0\n\n  while (neededAmount > planksCount && retries < maxRetries) {\n    retries++\n    const logsNeeded = Math.ceil((neededAmount - planksCount) / PLANKS_PER_LOG)\n\n    // Get all available log types in inventory\n    const availableLogs = mineflayer.bot.inventory\n      .items()\n      .filter(item => item.name.includes('log'))\n\n    // If no logs available, gather more wood\n    if (availableLogs.length === 0) {\n      logger.log(`Bot: Not enough logs. Gathering ${logsNeeded} logs.`)\n      try {\n        await gatherWood(mineflayer, logsNeeded, 80)\n      }\n      catch (error) {\n        throw new ActionError('RESOURCE_MISSING', 'Could not gather wood', { item: 'log', count: logsNeeded, originalError: error })\n      }\n\n      // Check if we actually got wood\n      const newLogs = mineflayer.bot.inventory.items().filter(item => item.name.includes('log'))\n      if (newLogs.length === 0) {\n        throw new ActionError('RESOURCE_MISSING', 'Gathered wood but inventory still empty of logs', { item: 'log' })\n      }\n      // Continue to next iteration to craft\n      continue\n    }\n\n    // Iterate over each log type to craft planks\n    let anyCrafted = false\n    for (const log of availableLogs) {\n      const logType = log.name.replace('_log', '') // Get log type without \"_log\" suffix\n      const logsToCraft = Math.min(log.count, logsNeeded)\n\n      logger.log(`Trying to make ${logsToCraft * PLANKS_PER_LOG} ${logType}_planks`)","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/skills/actions/ensure.ts#L42-L78","documentation":"Thrown by ensurePlanks() as an ActionError with code RESOURCE_MISSING. When the bot has no logs in inventory and needs planks, it calls gatherWood(mineflayer, logsNeeded, 80). If gatherWood itself throws (no trees in range, pathfinder failure, or the gather implementation rejected), the catch wraps it into 'Could not gather wood' with the original error preserved in context.originalError. This is a resource-acquisition failure: the bot cannot source raw logs to make planks.","triggerScenarios":"No trees within the 80-block gather radius; trees exist but pathfinder cannot reach them (terrain, water, claims); gatherWood threw because the bot is stuck or low on health; the world has no logs at all (superflat, desert).","commonSituations":"Bot spawned in a treeless biome; gathered area depleted and no nearer trees; pathfinder stuck in a hole or surrounded by water; server anti-cheat blocking block breaking; gatherWood called while the bot is mid-combat or falling.","solutions":["Move the bot to a forest/jungle biome before requiring planks.","Catch ActionError RESOURCE_MISSING and fall back to trading, looting chests, or asking a player for logs.","Inspect context.originalError to find the underlying gatherWood failure (pathfinder vs. no-target).","Increase the gather radius or pre-stock logs via ensurePlanks' inventory check before they are needed."],"exampleFix":"// before\n//   await ensurePlanks(mineflayer, 4)  // throws RESOURCE_MISSING: Could not gather wood\n//\n// after\n//   try {\n//     await ensurePlanks(mineflayer, 4)\n//   } catch (e) {\n//     if (e instanceof ActionError && e.code === 'RESOURCE_MISSING') {\n//       await chat({ message: 'No wood nearby — please place logs near me' })\n//       return\n//     }\n//     throw e\n//   }","handlingStrategy":"try-catch","validationCode":"// Pre-stock logs so gather is unnecessary:\n// import { getItemCount } from './inventory'\n// if (getItemCount(mineflayer, 'log') < 1) {\n//   // move to a forest biome first, or request logs from a player\n// }","typeGuard":"function isResourceMissing(e: unknown): e is { code: 'RESOURCE_MISSING', context?: { originalError?: unknown }, message: string } {\n  return e instanceof Error && (e as any).name === 'ActionError' && (e as any).code === 'RESOURCE_MISSING'\n}","tryCatchPattern":"// try {\n//   await ensurePlanks(mineflayer, 4)\n// } catch (e) {\n//   if (isResourceMissing(e)) {\n//     await chat({ message: 'No wood nearby; please place logs near me' })\n//     return\n//   }\n//   throw e\n// }","preventionTips":["Move to a tree-rich biome before requiring planks.","Inspect context.originalError to find the underlying gatherWood cause.","Catch RESOURCE_MISSING and fall back to trading/chests/player help.","Pre-stock logs so the gather path is not reached."],"tags":["minecraft","ensure","resource-missing","gather-wood","planks"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}