bedrock-protocol
Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication and encryption. Help contribute.
This is a work in progress. You can track the progress in https://github.com/PrismarineJS/bedrock-protocol/pull/34.
Features
- Supports Minecraft Bedrock version 1.16.201, 1.16.210, 1.16.220
- Parse and serialize packets as JavaScript objects
- Automatically respond to keep-alive packets
- Proxy and mitm connections
- Client
- Server
- Autheticate clients with Xbox Live
- Ping status
- Robust test coverage.
- Easily extend with many other PrismarineJS projects, world providers, and more
- Optimized for rapidly staying up to date with Minecraft protocol updates.
Want to contribute on something important for PrismarineJS ? go to https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects
Installation
npm install bedrock-protocol
Usage
Client example
const bedrock = require('bedrock-protocol')
const client = bedrock.createClient({
host: 'localhost',
port: 19132,
username: 'Notch',
offline: true
})
client.on('text', (packet) => {
if (packet.source_name != client.options.username) {
client.queue('text', {
type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}`
})
}
})
Server example
Can't connect locally on Windows? See the faq
const bedrock = require('bedrock-protocol')
const server = new bedrock.createServer({
host: '0.0.0.0',
port: 19132,
version: '1.16.220',
})
server.on('connect', client => {
client.on('join', () => {
const d = new Date()
client.disconnect(`Good ${d.getHours() < 12 ? '§emorning§r' : '§3afternoon§r'} :)\n\nMy time is ${d.toLocaleString()} !`)
})
})
Ping example
const { ping } = require('bedrock-protocol')
ping({ host: 'play.cubecraft.net', port: 19132 }).then(res => {
console.log(res)
})
Documentation
For documentation on the protocol, and packets/fields see the proto.yml and types.yml files.
See API documentation
See faq
Testing
npm test
Debugging
You can enable some protocol debugging output using DEBUG
environment variable.
Through node.js, add process.env.DEBUG = 'minecraft-protocol'
at the top of your script.
Contribute
Please read CONTRIBUTING.md and https://github.com/PrismarineJS/prismarine-contribute
History
See history