moeru-ai/airi · error · Error
Unknown block type: ${name}${suggestion}
Error message
Unknown block type: ${name}${suggestion} What it means
Thrown by getNearestBlocks when, for a requested block name, McData.getBlockId(name) returns a falsy id — the name is not in the loaded minecraft-data block registry. The error includes a 'did you mean <closest>?' suffix when getClosestBlockName finds a fuzzy match. This is a plain Error and aborts the whole block-name mapping, so no scanning occurs.
Source
Thrown at integrations/minecraft/src/skills/world.ts:82
return empty_pos[i]
}
}
return undefined
}
export function getNearestBlocks(mineflayer: Mineflayer, blockTypes: string[] | string | null = null, distance: number = DEFAULT_SCAN_RADIUS, count: number = 10000): Block[] {
const mcData = McData.fromBot(mineflayer.bot)
const blockNames = blockTypes === null
? mcData.getAllBlocks(['air']).map(block => block.name)
: (Array.isArray(blockTypes) ? blockTypes : [blockTypes])
.map((name) => {
const id = mcData.getBlockId(name)
if (id)
return name
const closest = mcData.getClosestBlockName(name)
const suggestion = closest ? `; did you mean ${closest}?` : ''
throw new Error(`Unknown block type: ${name}${suggestion}`)
})
const blockNameSet = new Set(blockNames)
const positions = mineflayer.bot.findBlocks({
matching: block => block && blockNameSet.has(block.name),
maxDistance: distance,
count,
})
return positions
.map((pos) => {
const block = mineflayer.bot.blockAt(pos)
const dist = pos.distanceTo(mineflayer.bot.entity.position)
return block ? { block, distance: dist } : null
})
.filter((item): item is { block: Block, distance: number } => item !== null)
.sort((a, b) => a.distance - b.distance)
.map(item => item.block)View on GitHub (pinned to 27111382b4)
Solutions
- Use the snake_case registry id (e.g. 'oak_log'); verify with mcData.getBlockId(name) before calling.
- Leverage the suggested closest name in the error message to correct the input.
- Confirm the minecraft-data version aligns with the connected server.
Example fix
// before
getNearestBlocks(mineflayer, 'wood', 64)
// after
const mcData = McData.fromBot(mineflayer.bot)
if (!mcData.getBlockId('oak_log')) throw new Error('invalid block')
getNearestBlocks(mineflayer, 'oak_log', 64) Defensive patterns
Strategy: type-guard
Validate before calling
const mcData = McData.fromBot(mineflayer.bot)
if (!mcData.getBlockId(blockType)) {
const suggestion = mcData.getClosestBlockName(blockType)
throw new Error(`Invalid block type: ${blockType}${suggestion ? `; did you mean ${suggestion}?` : ''}`)
}
getNearestBlocks(mineflayer, blockType, distance, count) Type guard
function isUnknownBlockTypeError(e: unknown): boolean {
return e instanceof Error && /Unknown block type:/.test(e.message)
} Try / catch
try {
return getNearestBlocks(mineflayer, blockType, distance, count)
} catch (e) {
if (e instanceof Error && /Unknown block type:/.test(e.message)) {
// extract the 'did you mean' suggestion and retry with the corrected name
} else throw e
} Prevention
- Pre-validate block names with mcData.getBlockId before scanning.
- Use the 'did you mean' suggestion to auto-correct user input.
- Keep minecraft-data version aligned with the connected server.
When it happens
Trigger: Calling getNearestBlocks/getNearestBlock with a blockType that is not a valid registry id: 'wood' instead of 'oak_log', 'ore iron' instead of 'iron_ore', a display name, or a modded block absent from vanilla data.
Common situations: User/LLM supplied a display name or alias; minecraft-data version does not match the server (renamed blocks between versions, e.g. old 'log' names); modded blocks not in the data set; casing or separator differences.
Related errors
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/0db7e30d4e5c3355.
Report an issue: GitHub.