Closed chiteroman closed 5 months ago
After a real player disconnect from the server the bot can't open chests.
Downgrading mineflayer version, chaning Minecraft server version
Did you try any method from the API? No Did you try any example? Any error from those? No
const mineflayer = require('mineflayer') const autoeat = require('mineflayer-auto-eat').plugin const { Telegraf } = require('telegraf') const telegram = new Telegraf('*******') async function send(msg) { await telegram.telegram.sendMessage('*******', msg) } const bot = mineflayer.createBot({ host: '*******', username: '*******', auth: 'offline', version: '1.19.4' }) async function collect() { try { await bot.waitForChunksToLoad() await send('Empezando a recolectar y vender...') let blocks = bot.findBlocks({ matching: block => { return block.name === 'chest' }, useExtraInfo: block => { return block.name === 'chest' }, count: 8 }) if (blocks.length < 1) { send('No se ha encontrado ningún cofre :(') return } await send(String('Se han encontrado ' + blocks.length + ' cofres')) let items = 0; for (let i = 0; i < blocks.length; i++) { let vec = blocks[i] let block = bot.blockAt(vec) if (block) { let chest = await bot.openChest(block) let slots = chest.slots for (let i = 0; i < slots.length; i++) { let slot = slots[i] if (slot) { items += slot.count await bot.putAway(i) await new Promise(resolve => setTimeout(resolve, 200)) } } chest.close() bot.chat('/sell') bot.chat('/is deposit all') } } send('Se han recolectado ' + items + ' objetos') } catch (e) { console.log(e) send(e) } } bot.loadPlugin(autoeat) bot.autoEat.options.priority = 'foodPoints' bot.autoEat.options.startAt = 19 bot.autoEat.options.bannedFood.push('golden_apple') telegram.on('text', async (ctx) => { if (ctx.update.message.chat.id.toString() === '******') { const msg = String(ctx.update.message.text) if (msg === 'RECOLECTAR') { collect() return } bot.chat(msg) } }) telegram.launch() bot.on('kicked', console.log) bot.on('error', (err) => { send(err) console.log(err) }) bot.on('end', () => { send('Bot desconectado :(') }) bot.on('login', () => { bot.chat('/login *******') }) bot.on('autoeat_started', () => { console.log('Auto Eat ha empezado') }) bot.on('autoeat_stopped', () => { console.log('Auto Eat paro') }) bot.once('spawn', async () => { await bot.waitForChunksToLoad() bot.once('windowOpen', async function open() { await bot.clickWindow(12, 0, 0) await send('Bot conectado') bot.removeListener('windowOpen', open) }) bot.setQuickBarSlot(0) bot.activateItem() await bot.waitForChunksToLoad() setInterval(collect, 5 * 60 * 1000); })
Open chest, recollect items and sell them without the presence of real player
Fixed adding 1 second delay between opening chests.
await new Promise(resolve => setTimeout(resolve, 1000))
Versions
Detailed description of a problem
After a real player disconnect from the server the bot can't open chests.
What did you try yet?
Downgrading mineflayer version, chaning Minecraft server version
Did you try any method from the API? No Did you try any example? Any error from those? No
Your current code
Expected behavior
Open chest, recollect items and sell them without the presence of real player