PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
5.07k stars 921 forks source link

bot.findblock Always returns null #1461

Closed satyamedh closed 3 years ago

satyamedh commented 3 years ago

Versions

Clear question

I am trying to get the bot to craft a wooden pickaxe for me, it said it cannot craft it. The function is a replica of the example(inventory.js). I did some debugging and found out that bot.findBlock always returns null. Even if the crafting table is right in front of the bot. I am a newbie :)

What did you try yet? Copy pasting the function again, checking syntax if it is correct etc

Did you try any method from the API? Did you try any example? Any error from those? inventory, pure inventory.js with no changes dosent either

Your current code

Please put here any custom code you tried yet.


inventory.js from examples

Additional context

Add any other context about the problem here.

TheDudeFromCI commented 3 years ago

Possible duplicate of https://github.com/PrismarineJS/mineflayer/issues/1405

TheDudeFromCI commented 3 years ago

Update 2: Looks like the example bot for inventory.js is using a hardcoded ID value. https://github.com/PrismarineJS/mineflayer/blob/6941b61f809b6da6928a09e8841d4d815b8d148f/examples/inventory.js#L135

This is more likely the issue here if it's happening on vanilla. IDs are not static across versions.

58 should be replaced with require('minecraft-data')(bot.version).blocksByName.crafting_table.id

satyamedh commented 3 years ago

@TheDudeFromCI That fixed it! also now it says I can make a wooden pickaxe, turns over, clicks on crafting table and stays there forever, no errors.

satyamedh commented 3 years ago

@TheDudeFromCI is it slow crafting?

TheDudeFromCI commented 3 years ago

Yes, crafting can be a bit slow. It should finish after a few moments, though.

satyamedh commented 3 years ago

I left it overnight, did nothing @TheDudeFromCI

On Fri, Nov 20, 2020 at 5:11 AM TheDudeFromCI notifications@github.com wrote:

Yes, crafting can be a bit slow. It should finish after a few moments, though.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/1461#issuecomment-730706025, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALLN6PH6OG47YYD7IFSDNTDSQWUKVANCNFSM4T3NAJ2A .

TheDudeFromCI commented 3 years ago

"slow" in this context is 30-60 seconds at most. If it doesn't finish after 1 minute, it's usually broken.

It's very possible the inventory example is experiencing a regression bug.

satyamedh commented 3 years ago

@TheDudeFromCI So How can I fix it?

TheDudeFromCI commented 3 years ago

Looking through the code, I don't see any reason why it shouldn't work. You should open a seperate bug report for this @satyamedh

satyamedh commented 3 years ago

aight