Skip to content
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

BUG: when collecting multipleblocks #101

Open
0xrushi opened this issue Jul 7, 2022 · 0 comments
Open

BUG: when collecting multipleblocks #101

0xrushi opened this issue Jul 7, 2022 · 0 comments

Comments

@0xrushi
Copy link

0xrushi commented Jul 7, 2022

Sometimes the bot goes halfway on a tall block and gets stuck there because no path is left.
Giving Timeout: Took to long to decide path to goal! and exiting the code.

image

A quick workaround to this to the README code is add a collectGrass() in catch.

// Load collect block
bot.loadPlugin(require('mineflayer-collectblock').plugin)

async function collectGrass() {
  // Find a nearby grass block
  const grass = bot.findBlock({
    matching: mcData.blocksByName.spruce_log.id,
    maxDistance: 64
  })

  if (grass) {
    // If we found one, collect it.
    try {
      await bot.collectBlock.collect(grass)
      collectGrass() // Collect another grass block
    } catch (err) {
      console.log(err) // Handle errors, if any
      collectGrass()
    }
  }
}

// On spawn, start collecting all nearby grass
bot.once('spawn', () => {
  mcData = require('minecraft-data')(bot.version)
  collectGrass()
})

But I think since collectBlock has an option to collect multiple blocks, the collectAll function here https://github.com/rushic24/mineflayer-collectblock/blob/08997f52464c219bb4ce9fd1c5eafa9f3af02482/src/CollectBlock.ts#L18
should handle that single error and continue mining other blocks in the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant