• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PrismarineJS/bedrock-protocol: Minecraft Bedrock protocol library, with authenti ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

PrismarineJS/bedrock-protocol

开源软件地址(OpenSource Url):

https://github.com/PrismarineJS/bedrock-protocol

开源编程语言(OpenSource Language):

JavaScript 99.8%

开源软件介绍(OpenSource Introduction):

bedrock-protocol

NPM version Build Status Discord Try it on gitpod

Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication and encryption. Help contribute.

Protocol doc

Features

  • Supports Minecraft Bedrock version 1.16.201, 1.16.210, 1.16.220, 1.17.0, 1.17.10, 1.17.30, 1.17.40, 1.18.0, 1.18.11, 1.18.30, 1.19.1, 1.19.10, 1.19.20
  • 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

Example to connect to a server in offline mode, and relay chat messages back:

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.
})

client.on('text', (packet) => { // Listen for chat messages and echo them back.
  if (packet.source_name != client.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()}`
    })
  }
})

Client example joining a Realm

Example to connect to a Realm that the authenticating account is owner of or has been invited to:

const bedrock = require('bedrock-protocol')
const client = bedrock.createClient({
  realms: {
    pickRealm: (realms) => realms[0] // Function which recieves an array of joined/owned Realms and must return a single Realm. Can be async
  }
})

Server example

Can't connect locally on Windows? See the faq

const bedrock = require('bedrock-protocol')
const server = bedrock.createServer({
  host: '0.0.0.0',       // optional. host to bind as.
  port: 19132,           // optional
  version: '1.17.10',   // 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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap