// lib/log-surroundings.js const interestingBlocks = [ 'coal_ore', 'iron_ore', 'diamond_ore', 'gold_ore', 'emerald_ore', 'redstone_ore', 'lapis_ore', 'copper_ore', 'oak_log', 'birch_log', 'spruce_log', 'crafting_table', 'furnace', 'chest', 'anvil', 'beacon', 'bell', 'lectern', 'enchanting_table', 'portal', 'villager', 'spawner', 'campfire' ]; module.exports = function logSurroundings(bot, db, sayWithPersona) { try { const blocks = bot.findBlocks({ matching: block => interestingBlocks.includes(block.name), maxDistance: 12, count: 10 }); for (const pos of blocks) { const block = bot.blockAt(pos); if (!block || !block.name) continue; const label = `found-${block.name}-${pos.x},${pos.y},${pos.z}`; db.run( `INSERT OR IGNORE INTO memory (label, data) VALUES (?, ?)`, [label, JSON.stringify(pos)], (err) => { if (err) { console.error("DB insert failed in logSurroundings:", err); } } ); } } catch (err) { console.error("logSurroundings failed:", err); sayWithPersona("your brain short-circuited while trying to remember stuff."); } };