mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-22 14:12:07 +02:00
fixed get blocks, added deepslate ores
This commit is contained in:
parent
0d5a4d8562
commit
28dba87334
2 changed files with 9 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue