From 28dba873340dde8ef3f771d36d0521a72e683db8 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 27 Jan 2024 19:17:36 -0600 Subject: [PATCH] fixed get blocks, added deepslate ores --- src/agent/library/skills.js | 6 +++++- src/agent/library/world.js | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index 9cc8583..d2a76e9 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -331,8 +331,12 @@ export async function collectBlock(bot, blockType, num=1) { log(bot, `Invalid number of blocks to collect: ${num}.`); return false; } + let blocktypes = [blockType]; + if (blockType.endsWith('ore')) + blocktypes.push('deepslate_'+blockType); + let collected = 0; - const blocks = world.getNearestBlocks(bot, blockType, 64, num); + const blocks = world.getNearestBlocks(bot, blocktypes, 64, num); if (blocks.length === 0) { log(bot, `Could not find any ${blockType} to collect.`); return false; diff --git a/src/agent/library/world.js b/src/agent/library/world.js index cee82f0..52c4b74 100644 --- a/src/agent/library/world.js +++ b/src/agent/library/world.js @@ -49,9 +49,12 @@ export function getNearestBlocks(bot, block_types, distance=16, count=1) { * @example * let woodBlocks = world.getNearestBlocks(bot, ['oak_log', 'birch_log'], 16, 1); **/ + // if blocktypes is not a list, make it a list + if (!Array.isArray(block_types)) + block_types = [block_types]; let block_locs = bot.findBlocks({ matching: (block) => { - return block && block_types.includes(block.name); + return block && block_types.some(name => name === block.name); }, maxDistance: distance, count: count