No description
  • JavaScript 99.6%
  • Shell 0.4%
Find a file
extremeheat f0fbf4f859
Send skin data, protocol updates (#88)
* Add skin data

* Serialization updates
* Dynamic shield item id
* NBT reading/writing on void type uses 0 length, fix some third party servers

* Fix proxy empty chunk issue

* Fix scoreboards
compiler needs ../

* fix indentation

* Fix set_score packet

* Fix readme title auth doc

* Implement new compiler vars
2021-05-24 10:17:09 -04:00
.github Upgrade to GitHub-native Dependabot (#75) 2021-05-02 01:04:32 +02:00
data Send skin data, protocol updates (#88) 2021-05-24 10:17:09 -04:00
docs Support xbox title + live.com auth (#86) 2021-05-19 09:53:55 -04:00
examples Support xbox title + live.com auth (#86) 2021-05-19 09:53:55 -04:00
src Send skin data, protocol updates (#88) 2021-05-24 10:17:09 -04:00
test Fix third party servers, optional client encryption (#83) 2021-05-11 13:39:46 -04:00
tools Send skin data, protocol updates (#88) 2021-05-24 10:17:09 -04:00
types Enforce server auth, ping on createClient, update docs (#68) 2021-04-18 09:19:59 -04:00
.eslintignore viewer: working first person 2021-04-07 07:15:22 -04:00
.gitattributes Protocol updates, maps and rotation (#77) 2021-05-04 13:56:12 -04:00
.gitignore Remove old tests, lint tests 2021-03-23 03:28:50 -04:00
.gitpod setup some CI and basics (#47) 2021-03-14 00:49:17 +01:00
.gitpod.DockerFile setup some CI and basics (#47) 2021-03-14 00:49:17 +01:00
.npmignore Enforce server auth, ping on createClient, update docs (#68) 2021-04-18 09:19:59 -04:00
.npmrc setup some CI and basics (#47) 2021-03-14 00:49:17 +01:00
AUTHORS.md Add babel for esnext support. 2019-07-14 17:21:20 +02:00
babel.config.js Standard (#44) 2021-03-13 19:38:31 +01:00
CONTRIBUTING.md Add relay proxy to tests, docs, fix offline (#71) 2021-04-21 06:22:51 -04:00
HISTORY.md Release 3.1.0 2021-05-05 12:20:27 +02:00
index.d.ts Support xbox title + live.com auth (#86) 2021-05-19 09:53:55 -04:00
index.js Support xbox title + live.com auth (#86) 2021-05-19 09:53:55 -04:00
LICENSE initial commit 2016-02-13 13:09:13 -05:00
package.json Send skin data, protocol updates (#88) 2021-05-24 10:17:09 -04:00
README.md Send skin data, protocol updates (#88) 2021-05-24 10:17:09 -04:00

bedrock-protocol

NPM version Build Status Discord Try it on gitpod

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',   // optional
  port: 19132,         // optional, default 19132
  username: 'Notch',   // the username you want to join as, optional if online mode
  offline: true        // optional, default false. if true, do not login with Xbox Live. You will not be asked to sign-in if set to true.
  // Optional for some servers which verify the title ID:
  // authTitle: bedrock.title.MinecraftNintendoSwitch
})

client.on('text', (packet) => { // Listen for chat messages and echo them back.
  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',       // optional. host to bind as.
  port: 19132,           // optional
  version: '1.16.220',   // optional. The server version, latest if not specified. 
})

server.on('connect', client => {
  client.on('join', () => { // The client has joined the server.
    const d = new Date()  // Once client is in the server, send a colorful kick message
    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