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

Finding a chest, opening it. #20

Open
tomikjetu opened this issue Aug 26, 2020 · 6 comments
Open

Finding a chest, opening it. #20

tomikjetu opened this issue Aug 26, 2020 · 6 comments

Comments

@tomikjetu
Copy link

Minecraft version 1.16.1
Hello, I found this example of chest opening and withdrawing items. https://github.com/PrismarineJS/mineflayer/blob/1abfe102766175b27fa39cb6cf587da6fc9a2d9a/examples/chest.js
But I couldn't find a chest.
So I found this plugin and tried the usage example.
I lowered the maxDistance, otherwise, it crashes. I placed a diamond ore next to the player, and it didn't find a single block.
It just returns an empty array

If there's no way to fix this. Is there a way to open a chest at given coords? (constructing a Block)

@rom1504
Copy link
Contributor

rom1504 commented Aug 26, 2020 via email

@tomikjetu
Copy link
Author

tomikjetu commented Aug 26, 2020

@rom1504 I figured out a better way I think. Specifying the coords of the chest, finding a bock at the coords, opening it.
It will also open the right chest.

Anyway can you please refer to the documentation of findBlocks

This is the fix i've done

  for (var item of openChest.items()) {
    openChest.withdraw(item.type, null, item.count, (err) => {
      if (err) console.log(err)
    })
    await sleep(500) //otherwise it throws error: server rejected transaction
  }

@rom1504
Copy link
Contributor

rom1504 commented Aug 26, 2020 via email

@tomikjetu
Copy link
Author

@rom1504 Callback where? Should it be the callback on withdraw function? Can you provide an example?

@tomikjetu
Copy link
Author

Also are item types listed somewhere? Melon is 735. Doesn't seem like actual ids..

@rom1504
Copy link
Contributor

rom1504 commented Aug 26, 2020 via email

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

2 participants