fixed get blocks, added deepslate ores

This commit is contained in:
MaxRobinsonTheGreat 2024-01-27 19:17:36 -06:00
parent 0d5a4d8562
commit 28dba87334
2 changed files with 9 additions and 2 deletions

View file

@ -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;

View file

@ -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