Closed nikitapro225 closed 3 months ago
const mineflayer = require('mineflayer'); const { pathfinder, Movements, goals } = require('mineflayer-pathfinder'); const GoalBlock = goals.GoalBlock; var vec3 = require('vec3'); const webgui = require('mineflayer-web-inventory'); const Inventory = mineflayer.Inventory; bot = mineflayer.createBot({ host: 'localhost', port: 25565, username: 'Bot', version: '1.12.2' }) webgui(bot) bot.loadPlugin(pathfinder); bot.on('login', () => { console.log('\x1b[42m\x1b[30m[+] Logged in'); }) let java = ''; let isBusy = false; bot.on('whisper', (username, message, rawMessage) => { const args = message.split(' '); if (args[0] === 'kit') { if (args.length === 4) { const x = parseInt(args[1]); const y = parseInt(args[2]); const z = parseInt(args[3]); if (isNaN(x) || isNaN(y) || isNaN(z)) { bot.whisper(username, 'Invalid coordinates. Please enter valid numbers for x, y, and z.'); } else { if (bot.pathfinder.isMoving()){ bot.whisper(username, 'I\'m busy right now. Please try again later.'); } else { java = username; console.log(`\x1b[42m\x1b[30m[+] Delivery! ${x}, ${y}, ${z}`); //bot.whisper(username, `Kit coordinates: `); isBusy = true; const targetBlock = new vec3(-131, 71, -194); const block = bot.blockAt(targetBlock); if (block && block.type === 54) { // 54 is the block ID for a chest bot.openChest(block); } else { console.error(`Cannot find a chest at ${targetBlock.x}, ${targetBlock.y}, ${targetBlock.z}`); bot.whisper(username, 'Cannot find a chest at the specified coordinates.'); } bot.once('chest_open', (chest) => { const shulkerBoxSlot = chest.findInventoryItem('purple_shulker_box'); if (shulkerBoxSlot) { const shulkerBox = chest.takeItem(shulkerBoxSlot.index); console.log(shulkerBox); bot.equip(shulkerBox, 'hand', () => { const goal = new GoalBlock(x, y, z); bot.pathfinder.setGoal(goal); bot.once('goal_reached', () => { bot.placeBlock(x, y+1, z, 'shulker_box'); isBusy = false; bot.whisper(username, 'Done!'); }); }); } }); bot.whisper(username, 'I\'m going to you'); } // set busy to false after 5 seconds } } else { bot.whisper(username, 'Invalid kit command. Usage: kit <x> <y> <z>'); } } })
Not enough information
I fix my code