Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A high-level API over bedrock-protocol, styled after Mineflayer β€” designed for one bot or a hundred.


Table of Contents


πŸš€ About

rockbot turns bedrock-protocol's raw packet stream into a Mineflayer-style API β€” events, entity tracking, movement controls, chat β€” and then layers a Fleet primitive on top so you can spawn, manage, and coordinate N bots without managing N arrays of EventEmitters.

  • Mineflayer-style per-bot API β€” bot.chat(), bot.blockAt(), bot.pathfinder.goto(), bot.setControlState(), events, plugins
  • First-class fleet management β€” createFleet() with auth provider integration, named bots, event aggregation, sub-team groups
  • Automatic tick loop β€” PlayerAuthInput at 20hz keeps every bot alive regardless of what user code is doing
  • Entity tracking in real time β€” position, rotation, metadata for every player in view distance
  • Graceful shutdown β€” SIGINT/SIGTERM handled, clean disconnect on exit
  • Plugin system β€” Mineflayer-compatible plugin injection

⚑ Quickstart

Single bot

import { createBot } from 'rockbot'

const bot = createBot({
  host: 'play.lbsg.net',
  username: 'RockBot',
})

bot.on('spawn', () => {
  console.log(`${bot.username} spawned at ${bot.position}`)
  bot.chat('Hello from rockbot!')
})

bot.on('chat', (username, message) => {
  console.log(`<${username}> ${message}`)
})

Fleet of bots

import { createFleet } from 'rockbot'

const fleet = createFleet({
  defaults: { host: 'play.lbsg.net' },
  auth: { provider: 'file', source: './accounts.csv' },
})

fleet.on('spawn', (bot) => console.log(`${bot.username} joined`))
fleet.on('chat', (bot, user, msg) => console.log(`[${bot.name}] <${user}> ${msg}`))

await fleet.spawn(5)
fleet.broadcast('We come in peace.')

πŸ“¦ Installation

npm install @sectersion/rockbot

Requires Node.js 18+.


πŸ“– API Reference

createBot(options)

Option Type Default Description
host string '127.0.0.1' Server address
port number 19132 Server port
username string required Bot name
offline boolean false Skip Xbox Live auth
version string auto-detect Protocol version
viewDistance number 8 Chunk radius
connectTimeout number 9000 Connection timeout (ms)
plugins PluginDeclaration[] β€” Mineflayer-style plugins

Bot

const bot = createBot({ host: 'localhost', username: 'Bot1', offline: true })
Method Returns Description
bot.chat(msg) void Send chat message
bot.whisper(user, msg) void Send private message
bot.look(yaw, pitch) void Set rotation
bot.lookAt(point) void Look at a Vec3 position
bot.setControlState(control, bool) void Set movement flag
bot.clearControlStates() void Reset all movement flags
bot.quit(reason?) void Disconnect cleanly
bot.end(reason?) void Alias for quit

Movement controls: forward, back, left, right, jump, sneak, sprint

Property Type Description
bot.username string Current username
bot.entity Entity Self entity (id, position, rotation)
bot.entities Map<number, Entity> All tracked entities
bot.position Vec3 Current position
bot.rotation { yaw, pitch } Current rotation
bot.health number HP (0–20)
bot.food number Hunger (0–20)
bot.game object { dimension, difficulty, gameMode }
Event Arguments Description
spawn β€” Bot fully joined the server
login β€” Authenticated and connected
chat (username, message) Chat message received
whisper (username, message) Private message
message (text) System message
health β€” HP or food changed
entitySpawn (entity) Entity entered view distance
entityGone (entity) Entity left view distance
kicked (reason) Bot was kicked
error (error) Error occurred
end β€” Connection closed
respawn β€” Bot respawned after death
game β€” Game data received

createFleet(options)

Option Type Description
defaults Partial<BotOptions> Default options for every bot
auth AuthConfig Credential provider
plugins PluginDeclaration[] Fleet-level plugins

Fleet

const fleet = createFleet({
  defaults: { host: 'play.lbsg.net' },
  auth: { provider: 'file', source: './accounts.csv' },
})
Method Returns Description
fleet.spawn(n) Promise<Bot[]> Spawn N bots
fleet.spawn(opts) Promise<Bot> Spawn one with per-bot options
fleet.despawn(name) β€” Disconnect and remove a bot
fleet.despawnAll() β€” Disconnect all bots
fleet.bot(name) Bot | undefined Get a bot by name
fleet.broadcast(msg) β€” Chat from every bot
fleet.group(names) Group Create a sub-team
Event Arguments Description
spawn (bot) A bot joined
chat (bot, username, message) Any bot heard chat
kicked (bot, reason) A bot was kicked
end (bot) A bot disconnected
error (bot, error) A bot error

Group

const miners = fleet.group(['miner-1', 'miner-2'])
miners.broadcast('Starting dig job!')
const results = await miners.call('chat', 'ready')
Method Description
group.add(bot) Add a bot
group.remove(bot) Remove a bot
group.broadcast(msg) Chat from all group members
group.call(method, ...args) Call a method on all bots in parallel
group.on(event, fn) Forward events from group bots

πŸ” Auth

File provider (CSV)

username,password,email
BotOne,pass123,bot1@example.com
BotTwo,pass456,bot2@example.com
createFleet({
  auth: { provider: 'file', source: './accounts.csv' },
})

Environment provider

createFleet({
  auth: { provider: 'env' },
})
// Reads: BOT_USERNAME, BOT_PASSWORD, BOT_EMAIL

Custom provider

import type { AuthProvider, Account } from 'rockbot'

class MyAuth implements AuthProvider {
  async acquire(): Promise<Account> {
    return { username: 'Bot', token: '...' }
  }
  async release(account: Account, reason?: string): Promise<void> {}
}

createFleet({
  auth: { provider: new MyAuth() },
})

πŸ”Œ Plugins

Plugins inject functionality into a bot at construction time β€” same pattern as Mineflayer.

function autoEat(bot: Bot, options?: any) {
  bot.on('health', () => {
    if (bot.food < 6) bot.chat('/eat')
  })
}

const bot = createBot({
  host: 'localhost',
  username: 'Bot',
  offline: true,
  plugins: [[autoEat, { threshold: 10 }]],
})

Fleet-level plugins are automatically applied to every spawned bot.


πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              rockbot                        β”‚
β”‚                                            β”‚
β”‚  Bot           Mineflayer-style per-bot API β”‚
β”‚  β”œβ”€β”€ events    spawn, chat, health, ...    β”‚
β”‚  β”œβ”€β”€ tick      PlayerAuthInput at 20hz     β”‚
β”‚  └── plugins   Plugin injection            β”‚
β”‚                                            β”‚
β”‚  Fleet         Multi-bot manager           β”‚
β”‚  β”œβ”€β”€ spawn()   Auth provider integration   β”‚
β”‚  β”œβ”€β”€ group()   Sub-team coordination       β”‚
β”‚  └── events    Aggregated from all bots    β”‚
β”‚                                            β”‚
β”‚  AuthProvider  Pluggable credential source  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  bedrock-protocol                          β”‚
β”‚  (RakNet, Xbox Live, packet I/O)           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Dependencies

Package Role
bedrock-protocol RakNet networking, auth, packet I/O
vec3 3D vector math
minecraft-data Block/item ID registry

πŸ›  Development

git clone https://github.com/sectersion/rockbot
cd rockbot
npm install
npm run build

Test on a live server

npx tsx test/lifeboat.ts

The first run triggers a Microsoft device-code login flow β€” visit the printed URL, enter the code, and the bot connects.


πŸ“„ License

MIT

Built on the PrismarineJS ecosystem. Inspired by Mineflayer.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages