[x] The FAQ doesn't contain a resolution to my issue
Versions
mineflayer: ^4.20.1
server: vanilla
node: 21.4.0
Detailed description of a problem
I am in the process of creating a semi-autonomous bot and am working on the "craft" part. When I ask it to craft an item that does not require crafting tables, there are no problems. But when it needs to access a table, it searches for the table, goes to the table, looks at the table, interacts with the table (its arm moves as if interacting with it), and a few seconds later I get an error message (and it does not craft the item).
Error: Error: Event windowOpen did not fire within timeout of 20000ms at EventEmitter.craft
(Minecraft-Bot\node_modules\mineflayer\lib\plugins\craft.js:32:13)
at async Object.craftHoe Minecraft-Bot\src\components\Inventory\craft\craft.js:76:5)
at async EventEmitter.<anonymous> (Minecraft-Bot\src\components\chat\chat.js:44:25)
What did you try yet?
I tried to increase the timeout,
changing the minecraft server version (1.20 > 1.16)
Your current code
async function craftItem(bot, name, amount) {
amount = parseInt(amount, 10)
const item = bot.registry.itemsByName[name]
const craftingTableID = bot.registry.blocksByName.crafting_table.id
console.log(craftingTableID);
const craftingTable = bot.findBlock({
matching: craftingTableID,
maxDistance: 6
})
if (!craftingTable) {
bot.chat('no crafting table found')
return
}
if (item) {
const recipe = bot.recipesFor(item.id, null, 1, craftingTable)[0];
if (recipe) {
let requiresTable = recipe.requiresTable === false ? null : craftingTable;
if (requiresTable) {
try {
const goal = new GoalNear(craftingTable.position.x, craftingTable.position.y, craftingTable.position.z, 1);
await bot.pathfinder.goto(goal);
} catch (error) {
bot.chat('I can\'t go to craft table');
}
}
bot.chat(`I can make ${name}`)
try {
const result = await bot.craft(recipe, amount, requiresTable, { timeout: 30000 });
bot.chat(`did the recipe for ${name} ${amount} times`);
console.log('Crafting result:', result);
} catch (err) {
console.error('Error during crafting:', err);
bot.chat(`error making ${name}`)
}
} else {
bot.chat(`I cannot make ${name}`)
}
} else {
bot.chat(`unknown item: ${name}`)
}
}
Versions
Detailed description of a problem
I am in the process of creating a semi-autonomous bot and am working on the "craft" part. When I ask it to craft an item that does not require crafting tables, there are no problems. But when it needs to access a table, it searches for the table, goes to the table, looks at the table, interacts with the table (its arm moves as if interacting with it), and a few seconds later I get an error message (and it does not craft the item).
What did you try yet?
I tried to increase the timeout, changing the minecraft server version (1.20 > 1.16)
Your current code
Expected behavior
At least a window appears. and fix the error :(