mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 14:25:43 +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];
|
let blocktypes = [blockType];
|
||||||
if (blockType.endsWith('ore'))
|
if (blockType.endsWith('ore'))
|
||||||
blocktypes.push('deepslate_'+blockType);
|
blocktypes.push('deepslate_'+blockType);
|
||||||
|
if (blockType === 'dirt')
|
||||||
|
blocktypes.push('grass_block');
|
||||||
|
|
||||||
let collected = 0;
|
let collected = 0;
|
||||||
|
|
||||||
for (let i=0; i<num; i++) {
|
for (let i=0; i<num; i++) {
|
||||||
const blocks = world.getNearestBlocks(bot, blocktypes, 64);
|
let blocks = world.getNearestBlocks(bot, blocktypes, 64);
|
||||||
if (exclude) {
|
if (exclude) {
|
||||||
for (let position of exclude) {
|
for (let position of exclude) {
|
||||||
blocks = blocks.filter(
|
blocks = blocks.filter(
|
||||||
|
|
|
@ -25,11 +25,12 @@ export function getNearestFreeSpace(bot, size=1, distance=8) {
|
||||||
for (let z = 0; z < size; z++) {
|
for (let z = 0; z < size; z++) {
|
||||||
let top = bot.blockAt(empty_pos[i].offset(x, 0, z));
|
let top = bot.blockAt(empty_pos[i].offset(x, 0, z));
|
||||||
let bottom = bot.blockAt(empty_pos[i].offset(x, -1, 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;
|
empty = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!empty) break;
|
||||||
}
|
}
|
||||||
if (empty) {
|
if (empty) {
|
||||||
return empty_pos[i];
|
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)) {
|
for (let block of getNearbyBlocks(bot, distance, count)) {
|
||||||
if (block_types.includes(block.name)) {
|
if (block_types.includes(block.name)) {
|
||||||
blocks.push(block);
|
blocks.push(block);
|
||||||
if (blocks.length >= count)
|
if (count !== null && blocks.length >= count)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue