在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):PrismarineJS/bedrock-protocol开源软件地址(OpenSource Url):https://github.com/PrismarineJS/bedrock-protocol开源编程语言(OpenSource Language):JavaScript 99.8%开源软件介绍(OpenSource Introduction):bedrock-protocolMinecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication and encryption. Help contribute. Features
Want to contribute on something important for PrismarineJS ? go to https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects Installation
UsageClient exampleExample 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 RealmExample 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 exampleCan'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 exampleconst { ping } = require('bedrock-protocol')
ping({ host: 'play.cubecraft.net', port: 19132 }).then(res => {
console.log(res)
}) DocumentationFor documentation on the protocol, and packets/fields see the proto.yml and types.yml files. See faq Testing
DebuggingYou can enable some protocol debugging output using Through node.js, add ContributePlease read CONTRIBUTING.md and https://github.com/PrismarineJS/prismarine-contribute HistorySee history |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论