mineflayer
mineflayer copied to clipboard
Craft API
- [x] The FAQ doesn't contain a resolution to my issue
Versions
- mineflayer: 4.2.0
- server: Idk
- node: v14
Detailed description of a problem
Not sure if it's a bug or a feature but it's about the craft API.
The bot.craft does exactly like it's on the recipe but what if I want to put more ingredients and get more results on one single "craft"? I know the bot.craft has a count parameter but it just loops the "craftOnce" and craft 1 by 1, which is a problem in my case because if I do like count = 64, the bot just hangs at some point and crashes, probably sending too much packets and after it restarts, I can see the bot crafted 10~20 times, its slower than doing manually.
Imagine 1 Bone to 3 Bone Meal and I want to craft the whole stack of Bone
What did you try yet?
Tried using bot.craft with a high count and as it does 1 by 1, it hangs after sending too much packets to the server. Tried changing the recipe ingredients count, gets ignored. Tried changing the clickWindow method to put the whole stack instead 1 single item, no effect.
Your current code
let boneMealRecipe = bot.recipesFor(mcData.itemsByName["bone_meal"].id);
if(boneMealRecipe.length)
bot.craft(boneMealRecipe[0], 64);
Expected behavior
Be able to craft more result items in one craft instead of using the exact ingredients on the recipe and loop 1 by 1
Thanks for the snippet, but this didn't work for me, maybe something else missing? I replaced the window.js and all the other modified files on his fork but I'm getting errors when this runs and no items is moving. I'm on a 1.18.2 server
TypeError: Serialization error for play.toServer : SizeOf error for undefined : Cannot
read property 'length' of undefined
at eval (eval at compile (...\node_modules\protodef\src\compiler.js:258:12), <anonymous>:454:39)
at Object.packet_window_click (eval at compile (...\node_modules\protodef\src\compiler.js:258:12), <anonymous>:466:9)
at eval (eval at compile (...\node_modules\protodef\src\compiler.js:258:12), <anonymous>:806:64)
at packet (eval at compile (...\node_modules\protodef\src\compiler.js:258:12), <anonymous>:839:9)
at CompiledProtodef.sizeOf (...\node_modules\protodef\src\compiler.js:89:14)
at e.message (...\node_modules\protodef\src\compiler.js:96:40)
at tryCatch (...\node_modules\protodef\src\utils.js:50:16)
at CompiledProtodef.createPacketBuffer (...\node_modules\protodef\src\compiler.js:96:20)
at Serializer.createPacketBuffer (...\node_modules\protodef\src\serializer.js:12:23)
at Serializer._transform (...\node_modules\protodef\src\serializer.js:18:18) {
field: 'play.toServer'
}
Can you try https://github.com/PrismarineJS/mineflayer/pull/2418 ?
I tried it, it is better, doesn't crash the bot, but still as I can see, looping 1 by 1, which is so much slower than doing the whole stack and eventually the craft hangs before the count specified and I have to call bot.craft again for the rest. The server is not mine, so I should mention the bot usually runs on ~200ms ping.
looping 1 by 1, which is so much slower than doing the whole stack
The issue with crafting the whole stack is that mineflayer currently does not support shift clicking. If shift clicking was supported I could add that to my PR ^^
I think the issue is duplicated with https://github.com/PrismarineJS/mineflayer/issues/257#issuecomment-1407490544
The issue comes when request a windoOpen for second time is very slow compares has first rquest https://github.com/PrismarineJS/mineflayer/blob/20862737c733fecee92b78fa12ea360003126290/lib/plugins/craft.js#L24