mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 06:15:32 +02:00
fixing previous commit
This commit is contained in:
parent
43943653d3
commit
977ce1e767
2 changed files with 6 additions and 3 deletions
|
@ -359,11 +359,13 @@ export async function collectBlock(bot, blockType, num=1, exclude=null) {
|
|||
let blocktypes = [blockType];
|
||||
if (blockType.endsWith('ore'))
|
||||
blocktypes.push('deepslate_'+blockType);
|
||||
if (blockType === 'dirt')
|
||||
blocktypes.push('grass_block');
|
||||
|
||||
let collected = 0;
|
||||
|
||||
for (let i=0; i<num; i++) {
|
||||
const blocks = world.getNearestBlocks(bot, blocktypes, 64);
|
||||
let blocks = world.getNearestBlocks(bot, blocktypes, 64);
|
||||
if (exclude) {
|
||||
for (let position of exclude) {
|
||||
blocks = blocks.filter(
|
||||
|
|
|
@ -25,11 +25,12 @@ export function getNearestFreeSpace(bot, size=1, distance=8) {
|
|||
for (let z = 0; z < size; z++) {
|
||||
let top = bot.blockAt(empty_pos[i].offset(x, 0, z));
|
||||
let bottom = bot.blockAt(empty_pos[i].offset(x, -1, z));
|
||||
if (!top || !top.name == 'air' || !bottom || !bottom.diggable) {
|
||||
if (!top || !top.name == 'air' || !bottom || bottom.drops.length == 0 || !bottom.diggable) {
|
||||
empty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty) break;
|
||||
}
|
||||
if (empty) {
|
||||
return empty_pos[i];
|
||||
|
@ -75,7 +76,7 @@ export function getNearestBlocks(bot, block_types, distance=16, count=null) {
|
|||
for (let block of getNearbyBlocks(bot, distance, count)) {
|
||||
if (block_types.includes(block.name)) {
|
||||
blocks.push(block);
|
||||
if (blocks.length >= count)
|
||||
if (count !== null && blocks.length >= count)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue