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

Error: Event blockUpdate:(10651, 64, 99656) did not fire within timeout of 5000ms #2757

Open
1 task
rubencosta13 opened this issue Aug 27, 2022 · 11 comments
Open
1 task
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

@rubencosta13
Copy link

rubencosta13 commented Aug 27, 2022

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.4.0
  • server: vanilla/spigot/paper 1.12.2
  • node: 16.16.0

Detailed description of a problem

when using example farmer.js I got an error: Error: Event blockUpdate:(10651, 64, 99656) did not fire within timeout of 5000ms

What did you try yet?

Did you try any example? Any error from those? YES, the exact error I'm facing

Your current code

const mineflayer = require('mineflayer')
const prismarineViewer = require('prismarine-viewer')
const { mineflayer: mineflayerViewer } = require('prismarine-viewer');
const items = require('./items.json')
const { Vec3 } = require('vec3')


const bot = mineflayer.createBot({
  host: '6b6t.org',
  username: 'bot',
  password: 'password',
  version: '1.12.2'
})

bot.once('spawn', () => {
  mineflayerViewer(bot, { port: 3007, firstPerson: true }) // port is the minecraft server port, if first person is false, you get a bird's-eye view
})

bot.on('spawn', (cm) => {
  setTimeout(() => { 
    console.log('Task is running')
    bot.chat('/login password')
    bot.setControlState('forward', true)
  }, 2000);
  setTimeout(() => {
    bot.setControlState('forward', false);

  }, 6200)
  setTimeout(() => {
    // loop();
  }, 20000);
})

// To fish we have to give bot the seeds
// /give farmer wheat_seeds 64

function blockToSow () {
  return bot.findBlock({
    point: bot.entity.position,
    matching: 60,
    maxDistance: 250,
    useExtraInfo: (block) => {
      const blockAbove = bot.blockAt(block.position.offset(0, 1, 0))
      return !blockAbove || blockAbove.type === 0
    }
  })
}

function blockToHarvest () {
  return bot.findBlock({
    point: bot.entity.position,
    maxDistance: 260,
    matching: (block) => {
      return block && block.type === 296 && block.metadata === 7
    }
  })
}

async function loop () {
  try {
    while (1) {
      const toHarvest = blockToHarvest()
      if (toHarvest) {
        await bot.dig(toHarvest)
      } else {
        break
      }
    }
    while (1) {
      const toSow = blockToSow()
      if (toSow) {
        await bot.equip(295, 'hand')
        await bot.placeBlock(toSow, new Vec3(0, 1, 0))
      } else {
        break
      }
    }
  } catch (e) {
    console.log(e)
  }

  // No block to harvest or sow. Postpone next loop a bit
  setTimeout(loop, 1400)
}


bot.once('login', loop)

Expected behavior

It should farm

Additional context

Add any other context about the problem here.

@rubencosta13 rubencosta13 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 Aug 27, 2022
@rubencosta13
Copy link
Author

and like 99% of the examples result in bugs, you should specify the tested version for mineflayer

@extremeheat
Copy link
Member

open for PR

@rubencosta13
Copy link
Author

Any updates?

@Lyh0yh
Copy link

Lyh0yh commented Nov 11, 2022

hi bro
I have the same problem as you.
Have you solved the problem?

@rubencosta13
Copy link
Author

Not really.....

@maximmasiutin
Copy link
Contributor

Also confirm in 4.5.1

@iiCodeRedemption
Copy link

Still a thing in the latest version (4.20.0).

@RogiersJ03
Copy link

For now I just catch the error and ignore it.

for (const coord of blocksToFarm) {
        await new Promise( (resolve, reject) => {
            bot.pathfinder.setGoal(new GoalNear(coord.x, coord.y, coord.z, 1));

            bot.once('goal_reached', async () => {
                const block = bot.blockAt(coord, false);
                const seedItem = bot.inventory.items().find(item => item.name === "wheat_seeds");

                if (seedItem === undefined) {
                    bot.chat(`/tell ${username} I need seeds.`);

                    reject('NoSeeds');
                }

                try {
                    await bot.dig(block, true);
                    await bot.equip(seedItem, 'hand');

                    const position = bot.blockAt(new Vec3(coord.x, coord.y-1, coord.z));
                    await bot.placeBlock(position, new Vec3(0, 1, 0));

                    resolve();
                } catch (err) {
                    if (err.message.includes('Event') && err.message.includes('did not fire within timeout')) {
                        console.log('Timeout error occured.');
                        resolve();
                      } else {
                        console.log(err);

                        reject();
                      }
                }
            });
        });
    }

@zengya55
Copy link

  • I have the same problem in version 4.8.1

@boly38
Copy link
Contributor

boly38 commented Nov 29, 2024

  • I'm trying to placeBlock (usign mineflyer in 4.23.0 and minecraft aternos server version1.20.3) & I encounter this issue too
  • I equip one block in bot hand (ex. await bot.equip(bot.registry.itemsByName.crafting_table.id, 'hand')
  • and I add some log in my findClearPosition (cf gist) method used before placeBlock :
console.log(`==>> check position : ${targetPos} | block under is ${blockBelow?.name || 'null'}, at target bock is ${blockAtTarget?.name || 'null'}`);

This make me understand that depend on the block below, then the issue is reproduced:

  • crafting table + chest + blue_bed + ... (probably more.)(&avoid bot position ;))

To fix that it would be great to tell here (or remind or document) the good way to find clear position to place a block :) (as it's a common need) 👍

  • the provided gist link has been updated with botUtil___FIXED.js file as (quite enough) fixed sample, and maybe may help to improve doc/lib/both.

@boly38
Copy link
Contributor

boly38 commented Dec 22, 2024

(+reproduced same issue when bot is trying to place item at player position // possible fix in findClearPosition using round() => && targetPos.round() !== botPos.round())

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

8 participants