mineflayer-pathfinder
mineflayer-pathfinder copied to clipboard
goal_reached doesnt activate at all
this is my code, it can stand on top of the slab which is what I want, but I cant get goal_reached to activate so I can click on it, I dont know why its not working
function findAndMoveToBlock() {
const blockTypes = ['wooden_slab', 'brick_slab', 'stone_brick_slab', 'nether_brick_slab', 'quartz_slab', 'stone_slab', 'sandstone_slab', 'purpur_slab',
'wooden_stairs', 'brick_stairs', 'stone_brick_stairs', 'nether_brick_stairs', 'quartz_stairs', 'stone_stairs', 'sandstone_stairs', 'purpur_stairs'];
const blockIDs = blockTypes.map(type => bot.registry.blocksByName[type]?.id).filter(id => id !== undefined);
const startTime = performance.now();
bot.findBlock({
point: bot.entity.position,
matching: blockIDs,
maxDistance: 128,
count: 10,
}, (err, blocks) => {
if (err) {
console.log('Error finding blocks:', err);
return;
}
const time = (performance.now() - startTime).toFixed(2);
if (blocks.length > 0) {
const block = blocks[0];
const mcData = require('minecraft-data')(bot.version);
const movements = new Movements(bot, mcData);
movements.canDig = false;
movements.scaffoldingBlocks = [];
bot.pathfinder.setMovements(movements);
const goal = new GoalBlock(block.position.x, block.position.y, block.position.z);
bot.pathfinder.setGoal(goal, true);
bot.on('goal_reached', () => {
bot.chat(`Reached block at ${block.position.x}, ${block.position.y}, ${block.position.z} in ${time} ms.`);
});
} else {
bot.chat(`No blocks found in ${time} ms.`);
}
});
}