mirror of
https://github.com/guilhermewerner/tcc
synced 2025-06-15 06:25:04 +00:00
Create basic bot
This commit is contained in:
18
package.json
Normal file
18
package.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@guilhermewerner/tcc1",
|
||||
"version": "0.1.0",
|
||||
"repository": "https://github.com/GuilhermeWerner/TCC1",
|
||||
"author": "Guilherme Werner <guilhermewerner@tribufu.com>",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node ./src/bot.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"mineflayer": "^4.20.1",
|
||||
"prismarine-viewer": "^1.28.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^7.0.3"
|
||||
}
|
||||
}
|
1379
pnpm-lock.yaml
generated
Normal file
1379
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
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