Create basic bot

This commit is contained in:
2024-05-17 14:41:51 -03:00
parent db2089cb4a
commit 6e3e932648
3 changed files with 1421 additions and 0 deletions

24
src/bot.js Normal file
View File

@ -0,0 +1,24 @@
// Copyright (c) 2024 Guilherme Werner
// SPDX-License-Identifier: MIT
import mineflayer from "mineflayer";
import { mineflayer as mineflayerViewer } from "prismarine-viewer";
const bot = mineflayer.createBot({
host: 'localhost',
port: 25565,
username: 'Bot',
auth: 'offline'
})
bot.once('spawn', () => {
mineflayerViewer(bot, { port: 3000, firstPerson: true })
})
bot.on('chat', (username, message) => {
if (username === bot.username) return
bot.chat(message)
})
bot.on('kicked', console.log)
bot.on('error', console.log)