mirror of
https://github.com/guilhermewerner/tcc
synced 2025-06-16 23:15:08 +00:00
Create basic bot
This commit is contained in:
24
src/bot.js
Normal file
24
src/bot.js
Normal 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)
|
Reference in New Issue
Block a user