{"record":{"id":"c6adc0840326df9a","repo":"moeru-ai/airi","slug":"could-not-find-any-blocktype-in-range-blocks","errorCode":null,"errorMessage":"Could not find any ${blockType} in ${range} blocks.","messagePattern":"Could not find any (.+?) in (.+?) blocks\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"integrations/minecraft/src/skills/movement.ts","lineNumber":105,"sourceCode":"\n  return result\n}\n\nexport async function goToNearestBlock(\n  mineflayer: Mineflayer,\n  blockType: string,\n  minDistance = 2,\n  range = 64,\n): Promise<Block> {\n  const MAX_RANGE = 512\n  if (range > MAX_RANGE) {\n    log(mineflayer, `Maximum search range capped at ${MAX_RANGE}.`)\n    range = MAX_RANGE\n  }\n\n  const block = getNearestBlock(mineflayer, blockType, range)\n  if (!block) {\n    throw new Error(`Could not find any ${blockType} in ${range} blocks.`)\n  }\n\n  log(mineflayer, `Found ${blockType} at ${block.position}.`)\n  const result = await goToPosition(mineflayer, block.position.x, block.position.y, block.position.z, minDistance)\n  if (!result.ok) {\n    throw new Error(`Failed to reach ${blockType}: ${result.reason} — ${result.message}`)\n  }\n  return block\n}\n\nexport async function goToNearestEntity(\n  mineflayer: Mineflayer,\n  entityType: string,\n  minDistance = 2,\n  range = 64,\n): Promise<boolean> {\n  const entity = getNearestEntityWhere(\n    mineflayer,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/skills/movement.ts#L87-L123","documentation":"Thrown by goToNearestBlock when getNearestBlock(mineflayer, blockType, range) returns null — no block of blockType was found within the search range (capped at MAX_RANGE = 512). This is a plain Error (not an ActionError) raised before any pathfinding begins, so the navigation never starts.","triggerScenarios":"Calling goToNearestBlock(mineflayer, 'diamond_ore', 2, 64) when no diamond_ore block is loaded within 64 blocks; the blockType is valid but absent from the scanned area; the bot's loaded chunks do not contain the target.","commonSituations":"Searching for a rare ore without exploring; target block is outside loaded chunks; block type exists but is buried/obscured; searching near spawn where the resource has been mined out.","solutions":["Increase the range parameter (up to the 512 cap) to scan a larger area.","Explore/move the bot to load new chunks before searching.","Verify blockType is a valid registry name and actually exists in the current biome/dimension.","Call getNearestBlock directly first to detect absence without throwing, then react."],"exampleFix":"// before\nawait goToNearestBlock(mineflayer, 'diamond_ore', 2, 64)\n\n// after\nconst b = getNearestBlock(mineflayer, 'diamond_ore', 128)\nif (!b) {\n  // explore to load more chunks\n  return\n}\nawait goToNearestBlock(mineflayer, 'diamond_ore', 2, 128)","handlingStrategy":"validation","validationCode":"import { getNearestBlock } from '../world'\nconst block = getNearestBlock(mineflayer, blockType, range)\nif (!block) {\n  // explore to load new chunks, or widen range\n  throw new Error(`No ${blockType} within ${range} blocks`)\n}\nawait goToNearestBlock(mineflayer, blockType, minDistance, range)","typeGuard":"function isBlockNotFoundError(e: unknown): boolean {\n  return e instanceof Error && /Could not find any .* in .* blocks\\./.test(e.message)\n}","tryCatchPattern":"let range = 64\nwhile (range <= 512) {\n  try {\n    return await goToNearestBlock(mineflayer, blockType, minDistance, range)\n  } catch (e) {\n    if (e instanceof Error && /Could not find any/.test(e.message)) {\n      range = Math.min(range * 2, 512)\n    } else throw e\n  }\n}\nthrow new Error(`${blockType} not found within 512 blocks`)","preventionTips":["Call getNearestBlock directly to detect absence without throwing.","Widen the range progressively (up to the 512 cap) before giving up.","Explore/load new chunks before searching for rare blocks."],"tags":["minecraft","navigation","block-search","exploration"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}