Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No goal_reached Event at all #3370

Closed
overtimepog opened this issue May 4, 2024 · 0 comments
Closed

No goal_reached Event at all #3370

overtimepog opened this issue May 4, 2024 · 0 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@overtimepog
Copy link

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.`);
    }
  });
}
```js
@overtimepog overtimepog added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels May 4, 2024
@PrismarineJS PrismarineJS locked and limited conversation to collaborators May 12, 2024
@extremeheat extremeheat converted this issue into discussion #3379 May 12, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

1 participant