mineflayer
mineflayer copied to clipboard
Error: Event blockUpdate:(10651, 64, 99656) did not fire within timeout of 5000ms
- [ ] 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.
and like 99% of the examples result in bugs, you should specify the tested version for mineflayer
open for PR
Any updates?
hi bro I have the same problem as you. Have you solved the problem?
Not really.....
Also confirm in 4.5.1
Still a thing in the latest version (4.20.0).
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();
}
}
});
});
}