mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-22 06:02:07 +02:00
21 lines
638 B
JavaScript
21 lines
638 B
JavaScript
import { getAllBlockIds } from './mcdata.js';
|
|
|
|
|
|
/**
|
|
* Get a list of all nearby blocks.
|
|
* @param {Bot} bot - The bot to get nearby blocks for.
|
|
* @returns {string[]} - A list of all nearby blocks.
|
|
* @example
|
|
* let blocks = world.getNearbyBlocks(bot);
|
|
**/
|
|
export function getNearbyBlocks(bot) {
|
|
let positions = bot.findBlocks({'matching': getAllBlockIds(['air']), 'maxDistance': 16, 'count': 4096});
|
|
let found = [];
|
|
for (let i = 0; i < positions.length; i++) {
|
|
let block = bot.blockAt(positions[i]);
|
|
if (!found.includes(block.name)) {
|
|
found.push(block.name);
|
|
}
|
|
}
|
|
return found;
|
|
}
|