const bot = require('./bot').create() const items = require('./items') const { Vec3 } = require('vec3') function printWelcomeChat() { bot.chat('Cum Bot v0.1') bot.chat('<#46d61a>For a list of commands do !help') bot.chat('<#9d9e9e>-----------------------------------') } function printHelpmessage() { bot.chat("<#9d9e9e>-----------------------------------") bot.chat("<#46d61a>!spawn - Prints out the world spawn") bot.chat("<#46d61a>!goto - Send the bot to a position") bot.chat("<#46d61a>!follow - Follow you") bot.chat("<#46d61a>!come - Goto your current position") bot.chat("<#9d9e9e>-----------------------------------") } bot.once('login', () => { // printWelcomeChat() // bot.chatAddPattern( // /(!([a-z|A-Z])+)/, // 'command', // 'Someone issues a command' // ) }) bot.on('spawn', () => { //bot.chat('I spawned, watch out!') }) function handleCommand(command, message, func) { const result = new RegExp(command).exec(message); if (result) { func(result) } } function sayBlockUnder() { const block = bot.blockAt(bot.players[username].entity.position.offset(0, -1, 0)) bot.chat(`Block under you is ${block.displayName} in the ${block.biome.name} biome`) console.log(block) } function printStats() { bot.chat("Here are my current stats") bot.chat("Experience Level: " + bot.experience.level) bot.chat("Health: " + bot.health) bot.chat("Food: " + bot.food) } function handleMessage(username, message) { console.log(username + " sent message `" + message + "`") if (username === bot.username) return handleCommand("!help", message, (result) => printHelpmessage()) handleCommand("!spawn", message, (result) => bot.chat(`Spawn is at ${bot.spawnPoint}`)) handleCommand("!stats", message, (result) => printStats()) } bot.on('chat', (username, message) => { handleMessage(username, message) }) bot.on('whisper', (username, message, rawMessage) => { handleMessage(username, message); }) // bot.on('playerCollect', (collector, collected) => { // if (collector.type === 'player') { // const item = collected.getDroppedItem() // if (!item) // return // bot.chat(`${collector.username !== bot.username ? ("I'm so jealous. " + collector.username) : 'I '} collected ${item.count} ${item.displayName}`) // } // }) bot.on('error', console.log)