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

Event windowOpen did not fire within timeout of 20000ms at EventEmitter.craft (bot craft event) #3399

Open
1 task done
Oxooi opened this issue Jun 16, 2024 · 0 comments
Open
1 task done
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Oxooi
Copy link

Oxooi commented Jun 16, 2024

  • 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}`)
    }
}

Expected behavior

At least a window appears. and fix the error :(

@Oxooi Oxooi added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

1 participant