From be6f0cde9f7970a4f9aa376c589c58d8cb4187c3 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 31 Jan 2024 11:24:08 -0500 Subject: [PATCH 01/74] Update and rename CONTRIBUTING.md to docs/CONTRIBUTING.md (#475) --- README.md | 4 ++-- CONTRIBUTING.md => docs/CONTRIBUTING.md | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) rename CONTRIBUTING.md => docs/CONTRIBUTING.md (93%) diff --git a/README.md b/README.md index 0bc55c2..00b97b9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Official Discord](https://img.shields.io/static/v1.svg?label=OFFICIAL&message=DISCORD&color=blue&logo=discord&style=for-the-badge)](https://discord.gg/GsEFRM8) -Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication and encryption. Help [contribute](CONTRIBUTING.md). +Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication and encryption. Help [contribute](docs/CONTRIBUTING.md). [Protocol doc](https://prismarinejs.github.io/minecraft-data/?v=bedrock_1.19.10&d=protocol) @@ -126,7 +126,7 @@ Through node.js, add `process.env.DEBUG = 'minecraft-protocol'` at the top of yo ## Contribute -Please read [CONTRIBUTING.md](CONTRIBUTING.md) and https://github.com/PrismarineJS/prismarine-contribute +Please read [CONTRIBUTING.md](docs/CONTRIBUTING.md) and https://github.com/PrismarineJS/prismarine-contribute ## History diff --git a/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 93% rename from CONTRIBUTING.md rename to docs/CONTRIBUTING.md index fd23544..56d8f52 100644 --- a/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -110,37 +110,39 @@ The above roughly translates to the following JavaScript code to read a packet: ```js function read_position(stream) { const ret = {} - ret.x = stream.readSignedInt32LE() - ret.z = stream.readUnsignedInt32LE() - ret.y = stream.readFloat32LE() + ret.x = stream.readLI32() + ret.z = stream.readLU32() + ret.y = stream.readLF32() return ret } function read_player_position(stream) { const ret = {} ret.on_ground = Boolean(stream.readU8()) - ret.position = read_player_position(stream) + ret.position = read_position(stream) let __movement_reason = stream.readU8() let movement_reason = { 0: 'player_jump', 1: 'player_autojump', 2: 'player_sneak', 3: 'player_sprint', 4: 'player_fall' }[__movement_reason] switch (movement_reason) { case 'player_jump': case 'player_autojump': - ret.original_position = read_player_position(stream) - ret.jump_tick = stream.readInt64LE(stream) + ret.original_position = read_position(stream) + ret.jump_tick = stream.readLI64() break case 'player_fall': - ret.original_position = read_player_position(stream) + ret.original_position = read_position(stream) break default: break } ret.player_hunger = undefined if (movement_reason == 'player_sprint') ret.player_hunger = stream.readU8() ret.last_positions = [] - for (let i = 0; i < stream.readUnsignedVarInt(); i++) { + let __latest_positions_len = stream.readUnsignedVarInt() + for (let i = 0; i < __latest_positions_len; i++) { ret.last_positions.push(read_player_position(stream)) } ret.keys_down = [] - for (let i = 0; i < stream.readZigZagVarInt(); i++) { + let __keys_down_len = stream.readZigZagVarInt() + for (let i = 0; i < __keys_down_len; i++) { const ret1 = {} ret1.up = Boolean(stream.readU8()) ret1.down = Boolean(stream.readU8()) From d3161badc65f2eba4b6e7c9e974ca4e3529a7e94 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 7 Feb 2024 20:03:26 -0500 Subject: [PATCH 02/74] Compressor handling update for 1.20.60 (#479) * support compressor in header * use mcdata features * cleanup --- src/client.js | 13 ++++++++++ src/connection.js | 12 ++++----- src/server.js | 12 +++++++++ src/serverPlayer.js | 8 +++--- src/transforms/encryption.js | 22 +++++++++++++++-- src/transforms/framer.js | 48 ++++++++++++++++++++++++------------ 6 files changed, 88 insertions(+), 27 deletions(-) diff --git a/src/client.js b/src/client.js index b6bb0ac..af3666b 100644 --- a/src/client.js +++ b/src/client.js @@ -42,6 +42,7 @@ class Client extends Connection { this.validateOptions() this.serializer = createSerializer(this.options.version) this.deserializer = createDeserializer(this.options.version) + this._loadFeatures() KeyExchange(this, null, this.options) Login(this, null, this.options) @@ -55,6 +56,17 @@ class Client extends Connection { this.emit('connect_allowed') } + _loadFeatures () { + try { + const mcData = require('minecraft-data')('bedrock_' + this.options.version) + this.features = { + compressorInHeader: mcData.supportFeature('compressorInPacketHeader') + } + } catch (e) { + throw new Error(`Unsupported version: '${this.options.version}', no data available`) + } + } + connect () { if (!this.connection) throw new Error('Connect not currently allowed') // must wait for `connect_allowed`, or use `createClient` this.on('session', this._connect) @@ -120,6 +132,7 @@ class Client extends Connection { updateCompressorSettings (packet) { this.compressionAlgorithm = packet.compression_algorithm || 'deflate' this.compressionThreshold = packet.compression_threshold + this.compressionReady = true } sendLogin () { diff --git a/src/connection.js b/src/connection.js index bc1d56b..2fcbd62 100644 --- a/src/connection.js +++ b/src/connection.js @@ -65,7 +65,7 @@ class Connection extends EventEmitter { write (name, params) { this.outLog?.(name, params) if (name === 'start_game') this.updateItemPalette(params.itemstates) - const batch = new Framer(this.compressionAlgorithm, this.compressionLevel, this.compressionThreshold) + const batch = new Framer(this) const packet = this.serializer.createPacketBuffer({ name, params }) batch.addEncodedPacket(packet) @@ -91,7 +91,7 @@ class Connection extends EventEmitter { _tick () { if (this.sendQ.length) { - const batch = new Framer(this.compressionAlgorithm, this.compressionLevel, this.compressionThreshold) + const batch = new Framer(this) batch.addEncodedPackets(this.sendQ) this.sendQ = [] this.sendIds = [] @@ -115,7 +115,7 @@ class Connection extends EventEmitter { */ sendBuffer (buffer, immediate = false) { if (immediate) { - const batch = new Framer(this.compressionAlgorithm, this.compressionLevel, this.compressionThreshold) + const batch = new Framer(this) batch.addEncodedPacket(buffer) if (this.encryptionEnabled) { this.sendEncryptedBatch(batch) @@ -150,13 +150,11 @@ class Connection extends EventEmitter { // These are callbacks called from encryption.js onEncryptedPacket = (buf) => { const packet = Buffer.concat([Buffer.from([0xfe]), buf]) // add header - this.sendMCPE(packet) } onDecryptedPacket = (buf) => { const packets = Framer.getPackets(buf) - for (const packet of packets) { this.readPacket(packet) } @@ -167,11 +165,13 @@ class Connection extends EventEmitter { if (this.encryptionEnabled) { this.decrypt(buffer.slice(1)) } else { - const packets = Framer.decode(this.compressionAlgorithm, buffer) + const packets = Framer.decode(this, buffer) for (const packet of packets) { this.readPacket(packet) } } + } else { + throw Error('Bad packet header ' + buffer[0]) } } } diff --git a/src/server.js b/src/server.js index 5476455..355e79a 100644 --- a/src/server.js +++ b/src/server.js @@ -15,6 +15,7 @@ class Server extends EventEmitter { this.RakServer = require('./rak')(this.options.raknetBackend).RakServer + this._loadFeatures(this.options.version) this.serializer = createSerializer(this.options.version) this.deserializer = createDeserializer(this.options.version) this.advertisement = new ServerAdvertisement(this.options.motd, this.options.port, this.options.version) @@ -27,6 +28,17 @@ class Server extends EventEmitter { this.setCompressor(this.options.compressionAlgorithm, this.options.compressionLevel, this.options.compressionThreshold) } + _loadFeatures (version) { + try { + const mcData = require('minecraft-data')('bedrock_' + version) + this.features = { + compressorInHeader: mcData.supportFeature('compressorInPacketHeader') + } + } catch (e) { + throw new Error(`Unsupported version: '${version}', no data available`) + } + } + setCompressor (algorithm, level = 1, threshold = 256) { switch (algorithm) { case 'none': diff --git a/src/serverPlayer.js b/src/serverPlayer.js index ffb1961..89e100c 100644 --- a/src/serverPlayer.js +++ b/src/serverPlayer.js @@ -10,6 +10,7 @@ class Player extends Connection { constructor (server, connection) { super() this.server = server + this.features = server.features this.serializer = server.serializer this.deserializer = server.deserializer this.connection = connection @@ -23,8 +24,8 @@ class Player extends Connection { this.status = ClientStatus.Authenticating if (isDebug) { - this.inLog = (...args) => debug('S ->', ...args) - this.outLog = (...args) => debug('S <-', ...args) + this.inLog = (...args) => debug('-> S', ...args) + this.outLog = (...args) => debug('<- S', ...args) } // Compression is server-wide @@ -48,6 +49,7 @@ class Player extends Connection { client_throttle_scalar: 0 }) this._sentNetworkSettings = true + this.compressionReady = true } handleClientProtocolVersion (clientVersion) { @@ -152,7 +154,7 @@ class Player extends Connection { return } - this.inLog?.(des.data.name, serialize(des.data.params).slice(0, 200)) + this.inLog?.(des.data.name, serialize(des.data.params)) switch (des.data.name) { // This is the first packet on 1.19.30 & above diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index b02351b..ff067cc 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -36,7 +36,10 @@ function createEncryptor (client, iv) { // The send counter is represented as a little-endian 64-bit long and incremented after each packet. function process (chunk) { - const buffer = Zlib.deflateRawSync(chunk, { level: client.compressionLevel }) + const compressed = Zlib.deflateRawSync(chunk, { level: client.compressionLevel }) + const buffer = client.features.compressorInHeader + ? Buffer.concat([Buffer.from([0]), compressed]) + : compressed const packet = Buffer.concat([buffer, computeCheckSum(buffer, client.sendCounter, client.secretKeyBytes)]) client.sendCounter++ client.cipher.write(packet) @@ -70,7 +73,22 @@ function createDecryptor (client, iv) { return } - const buffer = Zlib.inflateRawSync(chunk, { chunkSize: 512000 }) + let buffer + if (client.features.compressorInHeader) { + switch (packet[0]) { + case 0: + buffer = Zlib.inflateRawSync(packet.slice(1), { chunkSize: 512000 }) + break + case 255: + buffer = packet.slice(1) + break + default: + client.emit('error', Error(`Unsupported compressor: ${packet[0]}`)) + } + } else { + buffer = Zlib.inflateRawSync(packet, { chunkSize: 512000 }) + } + client.onDecryptedPacket(buffer) } diff --git a/src/transforms/framer.js b/src/transforms/framer.js index 2452f01..c59dd4e 100644 --- a/src/transforms/framer.js +++ b/src/transforms/framer.js @@ -3,12 +3,13 @@ const zlib = require('zlib') // Concatenates packets into one batch packet, and adds length prefixs. class Framer { - constructor (compressor, compressionLevel, compressionThreshold) { + constructor (client) { // Encoding this.packets = [] - this.compressor = compressor || 'none' - this.compressionLevel = compressionLevel - this.compressionThreshold = compressionThreshold + this.compressor = client.compressionAlgorithm || 'none' + this.compressionLevel = client.compressionLevel + this.compressionThreshold = client.compressionThreshold + this.writeCompressor = client.features.compressorInHeader && client.compressionReady } // No compression in base class @@ -21,30 +22,45 @@ class Framer { } static decompress (algorithm, buffer) { - try { - switch (algorithm) { - case 'deflate': return zlib.inflateRawSync(buffer, { chunkSize: 512000 }) - case 'snappy': throw Error('Snappy compression not implemented') - case 'none': return buffer - default: throw Error('Unknown compression type ' + this.compressor) - } - } catch { - return buffer + switch (algorithm) { + case 0: + case 'deflate': + return zlib.inflateRawSync(buffer, { chunkSize: 512000 }) + case 1: + case 'snappy': + throw Error('Snappy compression not implemented') + case 'none': + case 255: + return buffer + default: throw Error('Unknown compression type ' + algorithm) } } - static decode (compressor, buf) { + static decode (client, buf) { // Read header if (buf[0] !== 0xfe) throw Error('bad batch packet header ' + buf[0]) const buffer = buf.slice(1) - const decompressed = this.decompress(compressor, buffer) + // Decompress + let decompressed + if (client.features.compressorInHeader && client.compressionReady) { + decompressed = this.decompress(buffer[0], buffer.slice(1)) + } else { + // On old versions, compressor is session-wide ; failing to decompress + // a packet will assume it's not compressed + try { + decompressed = this.decompress(client.compressionAlgorithm, buffer) + } catch (e) { + decompressed = buffer + } + } return Framer.getPackets(decompressed) } encode () { const buf = Buffer.concat(this.packets) const compressed = (buf.length > this.compressionThreshold) ? this.compress(buf) : buf - return Buffer.concat([Buffer.from([0xfe]), compressed]) + const header = this.writeCompressor ? [0xfe, 0] : [0xfe] + return Buffer.concat([Buffer.from(header), compressed]) } addEncodedPacket (chunk) { From c278a03f952d23320b80f8c09b6372d41eeff26a Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 7 Feb 2024 21:04:39 -0500 Subject: [PATCH 03/74] 1.20.61 support (#480) * Update README.md * Update options.js --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 00b97b9..1c439a3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index fb285bd..1e63098 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.20.50' +const CURRENT_VERSION = '1.20.61' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From 0132302e5343b7ca5bb493f606b6dc20ef46c1fb Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Thu, 8 Feb 2024 03:05:28 +0100 Subject: [PATCH 04/74] Release 3.34.0 (#481) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- HISTORY.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index a1054f2..e11f5ee 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 3.34.0 +* [1.20.61 support (#480)](https://github.com/PrismarineJS/bedrock-protocol/commit/c278a03f952d23320b80f8c09b6372d41eeff26a) (thanks @extremeheat) +* [Compressor handling update for 1.20.60 (#479)](https://github.com/PrismarineJS/bedrock-protocol/commit/d3161badc65f2eba4b6e7c9e974ca4e3529a7e94) (thanks @extremeheat) +* [Update and rename CONTRIBUTING.md to docs/CONTRIBUTING.md (#475)](https://github.com/PrismarineJS/bedrock-protocol/commit/be6f0cde9f7970a4f9aa376c589c58d8cb4187c3) (thanks @extremeheat) +* [Add flow and deviceType options to relay (#464)](https://github.com/PrismarineJS/bedrock-protocol/commit/842e66266f09e8670a644a618d0ac4157746cd43) (thanks @GameParrot) + ## 3.33.1 * [Fix zigzag type move in prismarine-nbt (#471)](https://github.com/PrismarineJS/bedrock-protocol/commit/7b74cbf7129646adc80d50304afce6240848cfae) (thanks @extremeheat) diff --git a/package.json b/package.json index f150728..ab63761 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.33.1", + "version": "3.34.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From ab93d0d0824bd0ace250fb73f703dc7b60ecd780 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 10 Feb 2024 02:11:32 -0500 Subject: [PATCH 05/74] Note `npm update` command in readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1c439a3..2350d37 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Want to contribute on something important for PrismarineJS ? go to https://githu `npm install bedrock-protocol` +To update bedrock-protocol (or any Node.js package) and its dependencies after a previous install, you must run `npm update --depth 9999` + ## Usage ### Client example From 914ed6840bedf94c485b449a151d8a4862405c01 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 9 Mar 2024 11:51:36 -0500 Subject: [PATCH 06/74] Move github-helper script to new gh-helpers (#485) --- .github/helper-bot/github-helper.js | 59 ----------------------------- .github/helper-bot/index.js | 2 +- .github/workflows/update-helper.yml | 4 +- 3 files changed, 3 insertions(+), 62 deletions(-) delete mode 100644 .github/helper-bot/github-helper.js diff --git a/.github/helper-bot/github-helper.js b/.github/helper-bot/github-helper.js deleted file mode 100644 index 08759b2..0000000 --- a/.github/helper-bot/github-helper.js +++ /dev/null @@ -1,59 +0,0 @@ -if (!process.env.CI) { - // mock a bunch of things for testing locally -- https://github.com/actions/toolkit/issues/71 - process.env.GITHUB_REPOSITORY = 'PrismarineJS/bedrock-protocol' - process.env.GITHUB_EVENT_NAME = 'issue_comment' - process.env.GITHUB_SHA = 'cb2fd97b6eae9f2c7fee79d5a86eb9c3b4ac80d8' - process.env.GITHUB_REF = 'refs/heads/master' - process.env.GITHUB_WORKFLOW = 'Issue comments' - process.env.GITHUB_ACTION = 'run1' - process.env.GITHUB_ACTOR = 'test-user' - module.exports = { getIssueStatus: () => ({}), updateIssue: () => {}, createIssue: () => {} } - return -} - -// const { Octokit } = require('@octokit/rest') // https://github.com/octokit/rest.js -const github = require('@actions/github') - -const token = process.env.GITHUB_TOKEN -const octokit = github.getOctokit(token) -const context = github.context - -async function getIssueStatus (title) { - // https://docs.github.com/en/rest/reference/search#search-issues-and-pull-requests - const existingIssues = await octokit.rest.search.issuesAndPullRequests({ - q: `is:issue repo:${process.env.GITHUB_REPOSITORY} in:title ${title}` - }) - // console.log('Existing issues', existingIssues) - const existingIssue = existingIssues.data.items.find(issue => issue.title === title) - - if (!existingIssue) return {} - - return { open: existingIssue.state === 'open', closed: existingIssue.state === 'closed', id: existingIssue.number } -} - -async function updateIssue (id, payload) { - const issue = await octokit.rest.issues.update({ - ...context.repo, - issue_number: id, - body: payload.body - }) - console.log(`Updated issue ${issue.data.title}#${issue.data.number}: ${issue.data.html_url}`) -} - -async function createIssue (payload) { - const issue = await octokit.rest.issues.create({ - ...context.repo, - ...payload - }) - console.log(`Created issue ${issue.data.title}#${issue.data.number}: ${issue.data.html_url}`) -} - -async function close (id, reason) { - if (reason) await octokit.rest.issues.createComment({ ...context.repo, issue_number: id, body: reason }) - const issue = await octokit.rest.issues.update({ ...context.repo, issue_number: id, state: 'closed' }) - console.log(`Closed issue ${issue.data.title}#${issue.data.number}: ${issue.data.html_url}`) -} - -if (process.env.CI) { - module.exports = { getIssueStatus, updateIssue, createIssue, close } -} diff --git a/.github/helper-bot/index.js b/.github/helper-bot/index.js index e9d5893..9231779 100644 --- a/.github/helper-bot/index.js +++ b/.github/helper-bot/index.js @@ -1,7 +1,7 @@ // Automatic version update checker for Minecraft bedrock edition. const fs = require('fs') const cp = require('child_process') -const helper = require('./github-helper') +const helper = require('gh-helpers') const latestVesionEndpoint = 'https://itunes.apple.com/lookup?bundleId=com.mojang.minecraftpe&time=' + Date.now() const changelogURL = 'https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs' diff --git a/.github/workflows/update-helper.yml b/.github/workflows/update-helper.yml index 84f2dfe..168dd04 100644 --- a/.github/workflows/update-helper.yml +++ b/.github/workflows/update-helper.yml @@ -15,8 +15,8 @@ jobs: uses: actions/setup-node@master with: node-version: 18.0.0 - - name: Install Github Actions toolkit - run: npm i @actions/github + - name: Install Github Actions helper + run: npm i gh-helpers # The env vars contain the relevant trigger information, so we don't need to pass it - name: Runs helper run: cd .github/helper-bot && node index.js From 5ee5744ec91301e70017801bd153365c382ff09e Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 9 Mar 2024 15:46:17 -0500 Subject: [PATCH 07/74] Update update helper for gh-helpers v0.1 Handle breaking changes to API --- .github/helper-bot/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/helper-bot/index.js b/.github/helper-bot/index.js index 9231779..e1bf56e 100644 --- a/.github/helper-bot/index.js +++ b/.github/helper-bot/index.js @@ -1,7 +1,7 @@ // Automatic version update checker for Minecraft bedrock edition. const fs = require('fs') const cp = require('child_process') -const helper = require('gh-helpers') +const helper = require('gh-helpers')() const latestVesionEndpoint = 'https://itunes.apple.com/lookup?bundleId=com.mojang.minecraftpe&time=' + Date.now() const changelogURL = 'https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs' @@ -103,7 +103,7 @@ async function fetchLatest () { const title = `Support Minecraft ${result.version}` - const issueStatus = await helper.getIssueStatus(title) + const issueStatus = await helper.getIssueStatus({ title }) if (supportedVersions.includes(version)) { if (issueStatus.open) { From d8e707112acc038b6c9564d9a21b2f977326e47f Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 13 Mar 2024 23:19:21 -0400 Subject: [PATCH 08/74] 1.20.71 --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2350d37..6d0346b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index 1e63098..ed4ff6c 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.20.61' +const CURRENT_VERSION = '1.20.71' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From 184339b9d4a37bddcd30853b59877fb30b9b0dbb Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Thu, 14 Mar 2024 04:32:19 +0100 Subject: [PATCH 09/74] Release 3.35.0 (#489) * Release 3.35.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index e11f5ee..31f8b4b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.35.0 +* [Support 1.20.71](https://github.com/PrismarineJS/bedrock-protocol/commit/d8e707112acc038b6c9564d9a21b2f977326e47f) (thanks @extremeheat) +* [Note `npm update` command in readme](https://github.com/PrismarineJS/bedrock-protocol/commit/ab93d0d0824bd0ace250fb73f703dc7b60ecd780) (thanks @extremeheat) + ## 3.34.0 * [1.20.61 support (#480)](https://github.com/PrismarineJS/bedrock-protocol/commit/c278a03f952d23320b80f8c09b6372d41eeff26a) (thanks @extremeheat) * [Compressor handling update for 1.20.60 (#479)](https://github.com/PrismarineJS/bedrock-protocol/commit/d3161badc65f2eba4b6e7c9e974ca4e3529a7e94) (thanks @extremeheat) diff --git a/package.json b/package.json index ab63761..18fe1e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.34.0", + "version": "3.35.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From a7ae528c1619afce3d95061d94851b9e4445ca6d Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 28 Mar 2024 16:06:06 -0400 Subject: [PATCH 10/74] update helper-bot for gh-helpers v0.2 --- .github/helper-bot/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/helper-bot/index.js b/.github/helper-bot/index.js index e1bf56e..3957200 100644 --- a/.github/helper-bot/index.js +++ b/.github/helper-bot/index.js @@ -103,10 +103,10 @@ async function fetchLatest () { const title = `Support Minecraft ${result.version}` - const issueStatus = await helper.getIssueStatus({ title }) + const issueStatus = await helper.findIssue({ title }) || {} if (supportedVersions.includes(version)) { - if (issueStatus.open) { + if (issueStatus.isOpen) { helper.close(issueStatus.id, `Closing as ${version} is now supported`) } console.log('Latest version is supported.') @@ -114,7 +114,7 @@ async function fetchLatest () { } - if (issueStatus.closed) { + if (issueStatus.isClosed) { // We already made an issue, but someone else already closed it, don't do anything else console.log('I already made an issue, but it was closed') return @@ -127,7 +127,7 @@ async function fetchLatest () { CloudburstMC: getCommitsInRepo('CloudburstMC/Protocol', version, currentVersionReleaseDate) }) - if (issueStatus.open) { + if (issueStatus.isOpen) { helper.updateIssue(issueStatus.id, issuePayload) } else { helper.createIssue(issuePayload) From 3e5158bebe9ae3bc684e3312cc67327fbf5b1ca7 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 28 Mar 2024 16:14:09 -0400 Subject: [PATCH 11/74] helper-bot fix --- .github/helper-bot/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/helper-bot/index.js b/.github/helper-bot/index.js index 3957200..748dd57 100644 --- a/.github/helper-bot/index.js +++ b/.github/helper-bot/index.js @@ -103,7 +103,7 @@ async function fetchLatest () { const title = `Support Minecraft ${result.version}` - const issueStatus = await helper.findIssue({ title }) || {} + const issueStatus = await helper.findIssue({ titleIncludes }) || {} if (supportedVersions.includes(version)) { if (issueStatus.isOpen) { From c65fea29169ae8079e1a303ce51f06b85eca3b3d Mon Sep 17 00:00:00 2001 From: extremeheat Date: Fri, 29 Mar 2024 01:32:53 -0400 Subject: [PATCH 12/74] helper-bot fix --- .github/helper-bot/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/helper-bot/index.js b/.github/helper-bot/index.js index 748dd57..8dffc6c 100644 --- a/.github/helper-bot/index.js +++ b/.github/helper-bot/index.js @@ -102,8 +102,7 @@ async function fetchLatest () { console.log(version, currentVersionReleaseDate, releaseNotes) const title = `Support Minecraft ${result.version}` - - const issueStatus = await helper.findIssue({ titleIncludes }) || {} + const issueStatus = await helper.findIssue({ titleIncludes: title }) || {} if (supportedVersions.includes(version)) { if (issueStatus.isOpen) { From bd32aa8d04555fa2fdc4ecd6abbeb6124e2ae8bb Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 25 Apr 2024 02:47:16 -0400 Subject: [PATCH 13/74] 1.20.80 --- src/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options.js b/src/options.js index ed4ff6c..8a54fa1 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.20.71' +const CURRENT_VERSION = '1.20.80' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From a4346f9638bb3243dbc16c1fda62237a8d463384 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Thu, 25 Apr 2024 09:09:02 +0200 Subject: [PATCH 14/74] Release 3.36.0 (#498) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- HISTORY.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 31f8b4b..07536fe 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +## 3.36.0 +* [1.20.80](https://github.com/PrismarineJS/bedrock-protocol/commit/bd32aa8d04555fa2fdc4ecd6abbeb6124e2ae8bb) (thanks @extremeheat) +* [helper-bot fix](https://github.com/PrismarineJS/bedrock-protocol/commit/c65fea29169ae8079e1a303ce51f06b85eca3b3d) (thanks @extremeheat) +* [helper-bot fix](https://github.com/PrismarineJS/bedrock-protocol/commit/3e5158bebe9ae3bc684e3312cc67327fbf5b1ca7) (thanks @extremeheat) +* [update helper-bot for gh-helpers v0.2](https://github.com/PrismarineJS/bedrock-protocol/commit/a7ae528c1619afce3d95061d94851b9e4445ca6d) (thanks @extremeheat) + ## 3.35.0 * [Support 1.20.71](https://github.com/PrismarineJS/bedrock-protocol/commit/d8e707112acc038b6c9564d9a21b2f977326e47f) (thanks @extremeheat) * [Note `npm update` command in readme](https://github.com/PrismarineJS/bedrock-protocol/commit/ab93d0d0824bd0ace250fb73f703dc7b60ecd780) (thanks @extremeheat) diff --git a/package.json b/package.json index 18fe1e4..437b391 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.35.0", + "version": "3.36.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 1ddc5251695fda670c70ea506e0d1d267997e053 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Fri, 26 Apr 2024 01:44:18 -0400 Subject: [PATCH 15/74] Update README --- HISTORY.md | 5 +---- README.md | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 07536fe..2f364b7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,8 +1,5 @@ ## 3.36.0 -* [1.20.80](https://github.com/PrismarineJS/bedrock-protocol/commit/bd32aa8d04555fa2fdc4ecd6abbeb6124e2ae8bb) (thanks @extremeheat) -* [helper-bot fix](https://github.com/PrismarineJS/bedrock-protocol/commit/c65fea29169ae8079e1a303ce51f06b85eca3b3d) (thanks @extremeheat) -* [helper-bot fix](https://github.com/PrismarineJS/bedrock-protocol/commit/3e5158bebe9ae3bc684e3312cc67327fbf5b1ca7) (thanks @extremeheat) -* [update helper-bot for gh-helpers v0.2](https://github.com/PrismarineJS/bedrock-protocol/commit/a7ae528c1619afce3d95061d94851b9e4445ca6d) (thanks @extremeheat) +* [Support 1.20.80](https://github.com/PrismarineJS/bedrock-protocol/commit/bd32aa8d04555fa2fdc4ecd6abbeb6124e2ae8bb) (thanks @extremeheat) ## 3.35.0 * [Support 1.20.71](https://github.com/PrismarineJS/bedrock-protocol/commit/d8e707112acc038b6c9564d9a21b2f977326e47f) (thanks @extremeheat) diff --git a/README.md b/README.md index 6d0346b..d5f590a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) From 16e15d80a5084a19ed2fbabc023789ee38922b3a Mon Sep 17 00:00:00 2001 From: Kaaaaii <72093371+Kaaaaii@users.noreply.github.com> Date: Fri, 31 May 2024 15:20:59 +0100 Subject: [PATCH 16/74] Fix typo in types (#501) `ClientStatus.Disconected` is now `ClientStatus.Disconnected` --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index c93b5a9..8474ecd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -63,7 +63,7 @@ declare module 'bedrock-protocol' { } enum ClientStatus { - Disconected, + Disconnected, Authenticating, Initializing, Initialized From 19ade45ea5b983512c6c621255b8c6e147fc80b7 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 13 Jun 2024 23:07:17 -0400 Subject: [PATCH 17/74] Update vanilla.js disable chunk tests Should be done separately in p-chunk repo or in mineflayer --- test/vanilla.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/vanilla.js b/test/vanilla.js index 7a24008..7573368 100644 --- a/test/vanilla.js +++ b/test/vanilla.js @@ -5,7 +5,7 @@ const { waitFor } = require('../src/datatypes/util') const { getPort } = require('./util') async function test (version) { - const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + (version.includes('1.19') ? '1.18.30' : version)) // TODO: Fix prismarine-chunk + // const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + (version.includes('1.19') ? '1.18.30' : version)) // TODO: Fix prismarine-chunk // Start the server, wait for it to accept clients, throws on timeout const port = await getPort() @@ -48,10 +48,10 @@ async function test (version) { client.queue('tick_sync', { request_time: BigInt(Date.now()), response_time: BigInt(Date.now()) }) }, 200) - client.on('level_chunk', async packet => { // Chunk read test - const cc = new ChunkColumn(packet.x, packet.z) - await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count) - }) + // client.on('level_chunk', async packet => { // Chunk read test + // const cc = new ChunkColumn(packet.x, packet.z) + // await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count) + // }) console.log('Awaiting join') From 5b2d78792c9b4c070d727a9028a6b3a266483e1c Mon Sep 17 00:00:00 2001 From: extremeheat Date: Fri, 14 Jun 2024 04:43:57 -0400 Subject: [PATCH 18/74] Support 1.21.0 --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d5f590a..f895dd6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index 8a54fa1..bdb3a1c 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.20.80' +const CURRENT_VERSION = '1.21.0' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From 1fee54f517f3c21ef01b7615f94d265dbb0a478e Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Fri, 14 Jun 2024 10:57:51 +0200 Subject: [PATCH 19/74] Release 3.37.0 (#505) * Release 3.37.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 2f364b7..9bee096 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.37.0 +* [Support 1.21.0](https://github.com/PrismarineJS/bedrock-protocol/commit/5b2d78792c9b4c070d727a9028a6b3a266483e1c) (thanks @CreeperG16) +* [Fix typo in types (#501)](https://github.com/PrismarineJS/bedrock-protocol/commit/16e15d80a5084a19ed2fbabc023789ee38922b3a) (thanks @Kaaaaii) + ## 3.36.0 * [Support 1.20.80](https://github.com/PrismarineJS/bedrock-protocol/commit/bd32aa8d04555fa2fdc4ecd6abbeb6124e2ae8bb) (thanks @extremeheat) diff --git a/package.json b/package.json index 437b391..43fb4a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.36.0", + "version": "3.37.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 84c5231b92df9f5f1a09b29a05e7abfed62f1c2b Mon Sep 17 00:00:00 2001 From: w0ahL <149548505+w0ahL@users.noreply.github.com> Date: Sun, 16 Jun 2024 16:51:22 -0400 Subject: [PATCH 20/74] Don't send now deprecated tick sync packets on 1.21 and newer (#504) * Tick Sync is now deprecated * Add new function here * Add check * Remove useless require by me * Fix --- src/connection.js | 4 ++++ src/createClient.js | 44 +++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/connection.js b/src/connection.js index 2fcbd62..ca862ee 100644 --- a/src/connection.js +++ b/src/connection.js @@ -39,6 +39,10 @@ class Connection extends EventEmitter { return this.options.protocolVersion >= (typeof version === 'string' ? Versions[version] : version) } + versionLessThanOrEqualTo (version) { + return this.options.protocolVersion <= (typeof version === 'string' ? Versions[version] : version) + } + startEncryption (iv) { this.encryptionEnabled = true this.inLog?.('Started encryption', this.sharedSecret, iv) diff --git a/src/createClient.js b/src/createClient.js index 154a8ae..9d14134 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -56,35 +56,41 @@ function connect (client) { }) client.queue('client_cache_status', { enabled: false }) - client.queue('tick_sync', { request_time: BigInt(Date.now()), response_time: 0n }) + + if (client.versionLessThanOrEqualTo('1.20.80')) client.queue('tick_sync', { request_time: BigInt(Date.now()), response_time: 0n }) + sleep(500).then(() => client.queue('request_chunk_radius', { chunk_radius: client.viewDistance || 10 })) }) - // Send tick sync packets every 10 ticks - const keepAliveInterval = 10 - const keepAliveIntervalBig = BigInt(keepAliveInterval) - let keepalive - client.tick = 0n - client.once('spawn', () => { - keepalive = setInterval(() => { - // Client fills out the request_time and the server does response_time in its reply. - client.queue('tick_sync', { request_time: client.tick, response_time: 0n }) - client.tick += keepAliveIntervalBig - }, 50 * keepAliveInterval) + if (client.versionLessThanOrEqualTo('1.20.80')) { + const keepAliveInterval = 10 + const keepAliveIntervalBig = BigInt(keepAliveInterval) - client.on('tick_sync', async packet => { - client.emit('heartbeat', packet.response_time) - client.tick = packet.response_time + let keepalive + client.tick = 0n + + client.once('spawn', () => { + keepalive = setInterval(() => { + // Client fills out the request_time and the server does response_time in its reply. + client.queue('tick_sync', { request_time: client.tick, response_time: 0n }) + client.tick += keepAliveIntervalBig + }, 50 * keepAliveInterval) + + client.on('tick_sync', async packet => { + client.emit('heartbeat', packet.response_time) + client.tick = packet.response_time + }) }) - }) - client.once('close', () => { - clearInterval(keepalive) - }) + client.once('close', () => { + clearInterval(keepalive) + }) + } } async function ping ({ host, port }) { const con = new RakClient({ host, port }) + try { return advertisement.fromServerName(await con.ping()) } finally { From c4593aa355d6ce9e2ac65cc2102cd9285a6b6449 Mon Sep 17 00:00:00 2001 From: TheLegendaryTrashcan <122332042+Ant767@users.noreply.github.com> Date: Fri, 5 Jul 2024 06:22:05 -0500 Subject: [PATCH 21/74] Fix example in README.md for 1.21 (#506) * Fix example in README.md for 1.21 * Update client.js * Update README.md --------- Co-authored-by: extremeheat --- README.md | 2 +- examples/client/client.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f895dd6..56760fc 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ const client = bedrock.createClient({ client.on('text', (packet) => { // Listen for chat messages from the server 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: '', + type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '', filtered_message: '', message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}` }) } diff --git a/examples/client/client.js b/examples/client/client.js index 7bbd028..9f17e57 100644 --- a/examples/client/client.js +++ b/examples/client/client.js @@ -10,7 +10,7 @@ const client = bedrock.createClient({ 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: '', + type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '', filtered_message: '', message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}` }) } From 5d3986924d3f262708d7c7e55a7f410f12c7903c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Papp?= <86970314+CreeperG16@users.noreply.github.com> Date: Thu, 11 Jul 2024 02:58:47 +0200 Subject: [PATCH 22/74] Support 1.21.2, and add missing versions to type definitions (#510) * Add missing versions to type definitions * Add support for 1.21.2 * Add 1.21.2 to README --- README.md | 2 +- index.d.ts | 2 +- src/options.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 56760fc..8502066 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/index.d.ts b/index.d.ts index 8474ecd..37a58ab 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ import { Realm } from 'prismarine-realms' import { ServerDeviceCodeResponse } from 'prismarine-auth' declare module 'bedrock-protocol' { - type Version = '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' + type Version = '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' export interface Options { // The string version to start the client or server as diff --git a/src/options.js b/src/options.js index bdb3a1c..bfbcf5b 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.0' +const CURRENT_VERSION = '1.21.2' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From a797201ecb6e163436578b416e230c5bf5f7eb65 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Thu, 11 Jul 2024 06:16:58 +0200 Subject: [PATCH 23/74] Release 3.38.0 (#514) --- HISTORY.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 9bee096..5099c20 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 3.38.0 +* [Support 1.21.2, and add missing versions to type definitions (#510)](https://github.com/PrismarineJS/bedrock-protocol/commit/5d3986924d3f262708d7c7e55a7f410f12c7903c) (thanks @CreeperG16) +* [Fix example in README.md for 1.21 (#506)](https://github.com/PrismarineJS/bedrock-protocol/commit/c4593aa355d6ce9e2ac65cc2102cd9285a6b6449) (thanks @Ant767) +* [Don't send now deprecated tick sync packets on 1.21 and newer (#504)](https://github.com/PrismarineJS/bedrock-protocol/commit/84c5231b92df9f5f1a09b29a05e7abfed62f1c2b) (thanks @w0ahL) + ## 3.37.0 * [Support 1.21.0](https://github.com/PrismarineJS/bedrock-protocol/commit/5b2d78792c9b4c070d727a9028a6b3a266483e1c) (thanks @CreeperG16) * [Fix typo in types (#501)](https://github.com/PrismarineJS/bedrock-protocol/commit/16e15d80a5084a19ed2fbabc023789ee38922b3a) (thanks @Kaaaaii) diff --git a/package.json b/package.json index 43fb4a8..500d161 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.37.0", + "version": "3.38.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 4c3f62567e0f6ce20b70ea23238fce8606011e95 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 17 Aug 2024 20:03:02 -0400 Subject: [PATCH 24/74] update disconnect packet --- src/client.js | 3 ++- src/serverPlayer.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index af3666b..87e3705 100644 --- a/src/client.js +++ b/src/client.js @@ -183,7 +183,8 @@ class Client extends Connection { if (this.status === ClientStatus.Disconnected) return this.write('disconnect', { hide_disconnect_screen: hide, - message: reason + message: reason, + filtered_message: '' }) this.close(reason) } diff --git a/src/serverPlayer.js b/src/serverPlayer.js index 89e100c..4ef5243 100644 --- a/src/serverPlayer.js +++ b/src/serverPlayer.js @@ -117,7 +117,8 @@ class Player extends Connection { if (this.status === ClientStatus.Disconnected) return this.write('disconnect', { hide_disconnect_screen: hide, - message: reason + message: reason, + filtered_message: '' }) this.server.conLog('Kicked ', this.connection?.address, reason) setTimeout(() => this.close('kick'), 100) // Allow time for message to be recieved. From 3be55777fab4949179d3a7108ee29bbd8fada5a7 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 17 Aug 2024 20:52:54 -0400 Subject: [PATCH 25/74] 1.21.20 --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8502066..dc21fa0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.20 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index bfbcf5b..54fc596 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.2' +const CURRENT_VERSION = '1.21.20' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From 418efa1da63a9d2f1ddba70111a8273f0a4f881e Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Sun, 18 Aug 2024 03:18:52 +0200 Subject: [PATCH 26/74] Release 3.39.0 (#522) --- HISTORY.md | 4 ++++ README.md | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 5099c20..e67115f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.39.0 +* [1.21.20](https://github.com/PrismarineJS/bedrock-protocol/commit/3be55777fab4949179d3a7108ee29bbd8fada5a7) (thanks @extremeheat) +* [update disconnect packet](https://github.com/PrismarineJS/bedrock-protocol/commit/4c3f62567e0f6ce20b70ea23238fce8606011e95) (thanks @extremeheat) + ## 3.38.0 * [Support 1.21.2, and add missing versions to type definitions (#510)](https://github.com/PrismarineJS/bedrock-protocol/commit/5d3986924d3f262708d7c7e55a7f410f12c7903c) (thanks @CreeperG16) * [Fix example in README.md for 1.21 (#506)](https://github.com/PrismarineJS/bedrock-protocol/commit/c4593aa355d6ce9e2ac65cc2102cd9285a6b6449) (thanks @Ant767) diff --git a/README.md b/README.md index dc21fa0..6eaa35b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.20 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/package.json b/package.json index 500d161..1d9da0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.38.0", + "version": "3.39.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From cb530c8b45bf505f75e0e39241d88085c5564ae8 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Fri, 20 Sep 2024 01:07:47 -0400 Subject: [PATCH 27/74] Update tests (#528) * Debug * Update internal.js * Update internal.js * Update internal.js * Update internal.js --- test/internal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/internal.js b/test/internal.js index 6b37d95..de18cf8 100644 --- a/test/internal.js +++ b/test/internal.js @@ -14,7 +14,7 @@ function prepare (version) { async function startTest (version = CURRENT_VERSION, ok) { await prepare(version) - const Item = require('../types/Item')(version) + // const Item = require('../types/Item')(version) const port = await getPort() const server = new Server({ host: '0.0.0.0', port, version, offline: true }) @@ -56,7 +56,7 @@ async function startTest (version = CURRENT_VERSION, ok) { client.write('network_settings', { compression_threshold: 1 }) // Send some inventory slots for (let i = 0; i < 3; i++) { - client.queue('inventory_slot', { window_id: 'armor', slot: 0, item: new Item().toBedrock() }) + // client.queue('inventory_slot', { window_id: 'armor', slot: 0, item: new Item().toBedrock() }) } // client.queue('inventory_transaction', get('packets/inventory_transaction.json')) From fc30c96135ec20dca1257f702152cba61d4a59be Mon Sep 17 00:00:00 2001 From: poekcosimo <96430819+pokecosimo@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:50:40 +0200 Subject: [PATCH 28/74] 1.21.30 support (#527) --- README.md | 2 +- index.d.ts | 2 +- src/options.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6eaa35b..2041abd 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/index.d.ts b/index.d.ts index 37a58ab..65dbda1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ import { Realm } from 'prismarine-realms' import { ServerDeviceCodeResponse } from 'prismarine-auth' declare module 'bedrock-protocol' { - type Version = '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' + type Version = '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' export interface Options { // The string version to start the client or server as diff --git a/src/options.js b/src/options.js index 54fc596..ece9293 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.20' +const CURRENT_VERSION = '1.21.30' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From 391ea9814c7b760b1554f44b3411a469a2942104 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Fri, 20 Sep 2024 10:04:13 +0200 Subject: [PATCH 29/74] Release 3.40.0 (#529) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- HISTORY.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index e67115f..04561e9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.40.0 +* [1.21.30 support (#527)](https://github.com/PrismarineJS/bedrock-protocol/commit/fc30c96135ec20dca1257f702152cba61d4a59be) (thanks @pokecosimo) +* [Update tests (#528)](https://github.com/PrismarineJS/bedrock-protocol/commit/cb530c8b45bf505f75e0e39241d88085c5564ae8) (thanks @extremeheat) + ## 3.39.0 * [1.21.20](https://github.com/PrismarineJS/bedrock-protocol/commit/3be55777fab4949179d3a7108ee29bbd8fada5a7) (thanks @extremeheat) * [update disconnect packet](https://github.com/PrismarineJS/bedrock-protocol/commit/4c3f62567e0f6ce20b70ea23238fce8606011e95) (thanks @extremeheat) diff --git a/package.json b/package.json index 1d9da0c..f3c7bc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.39.0", + "version": "3.40.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From cd937a45d04809e71e7e043a10a81f36daf7c23f Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 24 Oct 2024 22:02:07 -0400 Subject: [PATCH 30/74] Update startVanillaServer.js --- tools/startVanillaServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/startVanillaServer.js b/tools/startVanillaServer.js index 6d77006..d0f0b72 100644 --- a/tools/startVanillaServer.js +++ b/tools/startVanillaServer.js @@ -50,7 +50,7 @@ async function download (os, version, path = 'bds-') { try { fs.mkdirSync(dir) } catch { } process.chdir(path + version) // Enter server folder - const url = (os, version) => `https://minecraft.azureedge.net/bin-${os}/bedrock-server-${version}.zip` + const url = (os, version) => `https://www.minecraft.net/bedrockdedicatedserver/bin-${os}/bedrock-server-${version}.zip` let found = false From a4023b987b4653a6469d28802d84f0fadc7cb382 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 24 Oct 2024 22:14:34 -0400 Subject: [PATCH 31/74] Update options.js --- src/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options.js b/src/options.js index ece9293..8bd206f 100644 --- a/src/options.js +++ b/src/options.js @@ -8,7 +8,7 @@ const CURRENT_VERSION = '1.21.30' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) // Skip some low priority versions (middle major) on Github Actions to allow faster CI -const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10'] +const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10', '1.20.15', '1.20.30', '1.20.40', '1.20.50', '1.20.61', '1.20.71'] const testedVersions = process.env.CI ? Object.keys(Versions).filter(v => !skippedVersionsOnGithubCI.includes(v)) : Object.keys(Versions) const defaultOptions = { From dd5c4de4f2624c3654af66e9a40a65eb13de0850 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 24 Oct 2024 22:46:20 -0400 Subject: [PATCH 32/74] 1.21.42 --- README.md | 2 +- index.d.ts | 2 +- src/options.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2041abd..e78b6ea 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/index.d.ts b/index.d.ts index 65dbda1..ea1179a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ import { Realm } from 'prismarine-realms' import { ServerDeviceCodeResponse } from 'prismarine-auth' declare module 'bedrock-protocol' { - type Version = '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' + type Version = '1.21.42' | '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' export interface Options { // The string version to start the client or server as diff --git a/src/options.js b/src/options.js index 8bd206f..f156eee 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.30' +const CURRENT_VERSION = '1.21.42' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From fa730786d5f8c6c066fe221d92c99f4331b97dee Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Fri, 25 Oct 2024 05:00:42 +0200 Subject: [PATCH 33/74] Release 3.41.0 (#538) * Release 3.41.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 04561e9..1100487 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.41.0 +* [1.21.42 support](https://github.com/PrismarineJS/bedrock-protocol/commit/dd5c4de4f2624c3654af66e9a40a65eb13de0850) (thanks @CreeperG16) + ## 3.40.0 * [1.21.30 support (#527)](https://github.com/PrismarineJS/bedrock-protocol/commit/fc30c96135ec20dca1257f702152cba61d4a59be) (thanks @pokecosimo) * [Update tests (#528)](https://github.com/PrismarineJS/bedrock-protocol/commit/cb530c8b45bf505f75e0e39241d88085c5564ae8) (thanks @extremeheat) diff --git a/package.json b/package.json index f3c7bc4..71912dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.40.0", + "version": "3.41.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 911e0e890febc00102cd1e5406731e66f7bad0ef Mon Sep 17 00:00:00 2001 From: LucienHH <66429271+LucienHH@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:23:32 +0000 Subject: [PATCH 34/74] Dynamic compression & batch header (#544) --- src/client.js | 1 + src/connection.js | 4 ++-- src/server.js | 4 ++++ src/serverPlayer.js | 2 ++ src/transforms/framer.js | 11 +++++++---- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/client.js b/src/client.js index 87e3705..2d798e6 100644 --- a/src/client.js +++ b/src/client.js @@ -26,6 +26,7 @@ class Client extends Connection { this.compressionAlgorithm = this.versionGreaterThanOrEqualTo('1.19.30') ? 'none' : 'deflate' this.compressionThreshold = 512 this.compressionLevel = this.options.compressionLevel + this.batchHeader = 0xfe if (isDebug) { this.inLog = (...args) => debug('C ->', ...args) diff --git a/src/connection.js b/src/connection.js index ca862ee..eb01f7f 100644 --- a/src/connection.js +++ b/src/connection.js @@ -153,7 +153,7 @@ class Connection extends EventEmitter { // These are callbacks called from encryption.js onEncryptedPacket = (buf) => { - const packet = Buffer.concat([Buffer.from([0xfe]), buf]) // add header + const packet = this.batchHeader ? Buffer.concat([Buffer.from([this.batchHeader]), buf]) : buf this.sendMCPE(packet) } @@ -165,7 +165,7 @@ class Connection extends EventEmitter { } handle (buffer) { // handle encapsulated - if (buffer[0] === 0xfe) { // wrapper + if (!this.batchHeader || buffer[0] === this.batchHeader) { // wrapper if (this.encryptionEnabled) { this.decrypt(buffer.slice(1)) } else { diff --git a/src/server.js b/src/server.js index 355e79a..6d9aa79 100644 --- a/src/server.js +++ b/src/server.js @@ -24,6 +24,7 @@ class Server extends EventEmitter { this.clients = {} this.clientCount = 0 this.conLog = debug + this.batchHeader = 0xfe this.setCompressor(this.options.compressionAlgorithm, this.options.compressionLevel, this.options.compressionThreshold) } @@ -44,16 +45,19 @@ class Server extends EventEmitter { case 'none': this.compressionAlgorithm = 'none' this.compressionLevel = 0 + this.compressionHeader = 255 break case 'deflate': this.compressionAlgorithm = 'deflate' this.compressionLevel = level this.compressionThreshold = threshold + this.compressionHeader = 0 break case 'snappy': this.compressionAlgorithm = 'snappy' this.compressionLevel = level this.compressionThreshold = threshold + this.compressionHeader = 1 break default: throw new Error(`Unknown compression algorithm: ${algorithm}`) diff --git a/src/serverPlayer.js b/src/serverPlayer.js index 4ef5243..b7ef02d 100644 --- a/src/serverPlayer.js +++ b/src/serverPlayer.js @@ -28,10 +28,12 @@ class Player extends Connection { this.outLog = (...args) => debug('<- S', ...args) } + this.batchHeader = this.server.batchHeader // Compression is server-wide this.compressionAlgorithm = this.server.compressionAlgorithm this.compressionLevel = this.server.compressionLevel this.compressionThreshold = this.server.compressionThreshold + this.compressionHeader = this.server.compressionHeader this._sentNetworkSettings = false // 1.19.30+ } diff --git a/src/transforms/framer.js b/src/transforms/framer.js index c59dd4e..a2d9c4f 100644 --- a/src/transforms/framer.js +++ b/src/transforms/framer.js @@ -6,9 +6,11 @@ class Framer { constructor (client) { // Encoding this.packets = [] + this.batchHeader = client.batchHeader this.compressor = client.compressionAlgorithm || 'none' this.compressionLevel = client.compressionLevel this.compressionThreshold = client.compressionThreshold + this.compressionHeader = client.compressionHeader || 0 this.writeCompressor = client.features.compressorInHeader && client.compressionReady } @@ -38,7 +40,7 @@ class Framer { static decode (client, buf) { // Read header - if (buf[0] !== 0xfe) throw Error('bad batch packet header ' + buf[0]) + if (this.batchHeader && buf[0] !== this.batchHeader) throw Error(`bad batch packet header, received: ${buf[0]}, expected: ${this.batchHeader}`) const buffer = buf.slice(1) // Decompress let decompressed @@ -58,9 +60,10 @@ class Framer { encode () { const buf = Buffer.concat(this.packets) - const compressed = (buf.length > this.compressionThreshold) ? this.compress(buf) : buf - const header = this.writeCompressor ? [0xfe, 0] : [0xfe] - return Buffer.concat([Buffer.from(header), compressed]) + const shouldCompress = buf.length > this.compressionThreshold + const header = this.batchHeader ? [this.batchHeader] : [] + if (this.writeCompressor) header.push(shouldCompress ? this.compressionHeader : 255) + return Buffer.concat([Buffer.from(header), shouldCompress ? this.compress(buf) : buf]) } addEncodedPacket (chunk) { From 29c7b92d96a7182804020d00c3f3d554fc7407c5 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 4 Dec 2024 22:47:15 -0500 Subject: [PATCH 35/74] Update startVanillaServer.js --- tools/startVanillaServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/startVanillaServer.js b/tools/startVanillaServer.js index d0f0b72..2a2ef61 100644 --- a/tools/startVanillaServer.js +++ b/tools/startVanillaServer.js @@ -54,7 +54,7 @@ async function download (os, version, path = 'bds-') { let found = false - for (let i = 0; i < 8; i++) { // Check for the latest server build for version (major.minor.patch.BUILD) + for (let i = 0; i < 20; i++) { // Check for the latest server build for version (major.minor.patch.BUILD) const u = url(os, `${verStr}.${String(i).padStart(2, '0')}`) debug('Opening', u, Date.now()) let ret From 52358d72773e85cb02fae78769adbcc1238d4c2d Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 4 Dec 2024 23:13:16 -0500 Subject: [PATCH 36/74] Update internal tests for 1.21.50 --- test/internal.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/internal.js b/test/internal.js index de18cf8..1003a87 100644 --- a/test/internal.js +++ b/test/internal.js @@ -47,6 +47,7 @@ async function startTest (version = CURRENT_VERSION, ok) { must_accept: false, has_scripts: false, behaviour_packs: [], + world_template: { uuid: '550e8400-e29b-41d4-a716-446655440000', version: '' }, // 1.21.50 texture_packs: [], resource_pack_links: [] }) From b4adf0484573f7e61aa019f111dc5ab32591b9d4 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 5 Dec 2024 00:05:30 -0500 Subject: [PATCH 37/74] Update vanilla test server setup (#550) * Update test server * lint --- package.json | 3 +- tools/startVanillaServer.js | 161 ++---------------------------------- 2 files changed, 10 insertions(+), 154 deletions(-) diff --git a/package.json b/package.json index 71912dc..192130d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "test": "mocha --bail --exit", "pretest": "npm run lint", "lint": "standard", - "vanillaServer": "node tools/startVanillaServer.js", + "vanillaServer": "minecraft-bedrock-server --root tools --version", "dumpPackets": "node tools/genPacketDumps.js", "fix": "standard --fix" }, @@ -40,6 +40,7 @@ "bedrock-protocol": "file:.", "bedrock-provider": "^2.0.0", "leveldb-zlib": "^1.0.1", + "minecraft-bedrock-server": "^1.4.2", "mocha": "^10.0.0", "protodef-yaml": "^1.1.0", "standard": "^17.0.0-2" diff --git a/tools/startVanillaServer.js b/tools/startVanillaServer.js index 2a2ef61..828e332 100644 --- a/tools/startVanillaServer.js +++ b/tools/startVanillaServer.js @@ -1,156 +1,11 @@ -const http = require('https') -const fs = require('fs') -const cp = require('child_process') -const debug = process.env.CI ? console.debug : require('debug')('minecraft-protocol') -const https = require('https') -const { getFiles, waitFor } = require('../src/datatypes/util') +const bedrockServer = require('minecraft-bedrock-server') -function head (url) { - return new Promise((resolve, reject) => { - const req = http.request(url, { method: 'HEAD', timeout: 1000 }, resolve) - req.on('error', reject) - req.on('timeout', () => { req.destroy(); debug('HEAD request timeout'); reject(new Error('timeout')) }) - req.end() - }) -} -function get (url, outPath) { - const file = fs.createWriteStream(outPath) - return new Promise((resolve, reject) => { - https.get(url, { timeout: 1000 * 20 }, response => { - if (response.statusCode !== 200) return reject(new Error('Server returned code ' + response.statusCode)) - response.pipe(file) - file.on('finish', () => { - file.close() - resolve() - }) - }) - }) -} - -// Get the latest versions -// TODO: once we support multi-versions -function fetchLatestStable () { - get('https://raw.githubusercontent.com/minecraft-linux/mcpelauncher-versiondb/master/versions.json', 'versions.json') - const versions = JSON.parse(fs.readFileSync('./versions.json')) - const latest = versions[0] - return latest.version_name -} - -// Download + extract vanilla server and enter the directory -async function download (os, version, path = 'bds-') { - debug('Downloading server', os, version, 'into', path) - process.chdir(__dirname) - const verStr = version.split('.').slice(0, 3).join('.') - const dir = path + version - - if (fs.existsSync(dir) && getFiles(dir).length) { - process.chdir(path + version) // Enter server folder - return verStr - } - try { fs.mkdirSync(dir) } catch { } - - process.chdir(path + version) // Enter server folder - const url = (os, version) => `https://www.minecraft.net/bedrockdedicatedserver/bin-${os}/bedrock-server-${version}.zip` - - let found = false - - for (let i = 0; i < 20; i++) { // Check for the latest server build for version (major.minor.patch.BUILD) - const u = url(os, `${verStr}.${String(i).padStart(2, '0')}`) - debug('Opening', u, Date.now()) - let ret - try { ret = await head(u) } catch (e) { continue } - if (ret.statusCode === 200) { - found = u - debug('Found server', ret.statusCode) - break - } - } - if (!found) throw Error('did not find server bin for ' + os + ' ' + version) - console.info('🔻 Downloading', found) - await get(found, 'bds.zip') - console.info('⚡ Unzipping') - // Unzip server - if (process.platform === 'linux') cp.execSync('unzip -u bds.zip && chmod +777 ./bedrock_server') - else cp.execSync('tar -xf bds.zip') - return verStr -} - -const defaultOptions = { - 'level-generator': '2', - 'server-port': '19130', - 'online-mode': 'false' -} - -// Setup the server -function configure (options = {}) { - const opts = { ...defaultOptions, ...options } - let config = fs.readFileSync('./server.properties', 'utf-8') - config += '\nplayer-idle-timeout=1\nallow-cheats=true\ndefault-player-permission-level=operator' - for (const o in opts) config += `\n${o}=${opts[o]}` - fs.writeFileSync('./server.properties', config) -} - -function run (inheritStdout = true) { - const exe = process.platform === 'win32' ? 'bedrock_server.exe' : './bedrock_server' - return cp.spawn(exe, inheritStdout ? { stdio: 'inherit' } : {}) -} - -let lastHandle - -// Run the server -async function startServer (version, onStart, options = {}) { - const os = process.platform === 'win32' ? 'win' : process.platform - if (os !== 'win' && os !== 'linux') { - throw Error('unsupported os ' + os) - } - await download(os, version, options.path) - configure(options) - const handle = lastHandle = run(!onStart) - handle.on('error', (...a) => { - console.warn('*** THE MINECRAFT PROCESS CRASHED ***', a) - handle.kill('SIGKILL') - }) - if (onStart) { - let stdout = '' - handle.stdout.on('data', data => { - stdout += data - if (stdout.includes('Server started')) onStart() - }) - handle.stdout.pipe(process.stdout) - handle.stderr.pipe(process.stdout) - } - return handle -} - -// Start the server and wait for it to be ready, with a timeout -async function startServerAndWait (version, withTimeout, options) { - let handle - await waitFor(async res => { - handle = await startServer(version, res, options) - }, withTimeout, () => { - handle?.kill() - throw new Error(`Server did not start on time (${withTimeout}ms, now ${Date.now()})`) - }) - return handle -} - -async function startServerAndWait2 (version, withTimeout, options) { - try { - return await startServerAndWait(version, 1000 * 60, options) - } catch (e) { - console.log(e) - console.log('^ Tring once more to start server in 10 seconds...') - lastHandle?.kill() - await new Promise(resolve => setTimeout(resolve, 10000)) - process.chdir(__dirname) - fs.rmSync('bds-' + version, { recursive: true }) - return await startServerAndWait(version, withTimeout, options) +module.exports = { + ...bedrockServer, + startServerAndWait (version, withTimeout, options) { + return bedrockServer.startServerAndWait(version, withTimeout, { ...options, root: __dirname }) + }, + startServerAndWait2 (version, withTimeout, options) { + return bedrockServer.startServerAndWait2(version, withTimeout, { ...options, root: __dirname }) } } - -if (!module.parent) { - // if (process.argv.length < 3) throw Error('Missing version argument') - startServer(process.argv[2] || '1.17.10', null, process.argv[3] ? { 'server-port': process.argv[3], 'online-mode': !!process.argv[4] } : undefined) -} - -module.exports = { fetchLatestStable, startServer, startServerAndWait, startServerAndWait2 } From 1c0836bff03d50cb12a3e45763eac6c9f605e00c Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 5 Dec 2024 00:44:03 -0500 Subject: [PATCH 38/74] 1.21.50 --- src/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options.js b/src/options.js index f156eee..dd42cdf 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.42' +const CURRENT_VERSION = '1.21.50' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From f48b50849a4394a132ecc17132650e9c1ab90b29 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Thu, 5 Dec 2024 07:08:37 +0100 Subject: [PATCH 39/74] Release 3.42.0 (#551) * Release 3.42.0 * Update HISTORY.md * Update README.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 4 ++++ README.md | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1100487..50ac34f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.42.0 +* [1.21.50 support](https://github.com/PrismarineJS/bedrock-protocol/commit/1c0836bff03d50cb12a3e45763eac6c9f605e00c) (thanks @extremeheat) +* [Dynamic compression & batch header (#544)](https://github.com/PrismarineJS/bedrock-protocol/commit/911e0e890febc00102cd1e5406731e66f7bad0ef) (thanks @LucienHH) + ## 3.41.0 * [1.21.42 support](https://github.com/PrismarineJS/bedrock-protocol/commit/dd5c4de4f2624c3654af66e9a40a65eb13de0850) (thanks @CreeperG16) diff --git a/README.md b/README.md index e78b6ea..25971a1 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/package.json b/package.json index 192130d..a87e71c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.41.0", + "version": "3.42.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 347e303ce422bdb6f6dfd4cba57d7d3937214707 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Mon, 9 Dec 2024 17:55:31 -0500 Subject: [PATCH 40/74] Remove protodef varint types (#552) Remove protodef types which are now natively in ProtoDef --- src/datatypes/compiler-minecraft.js | 70 +---------------------------- src/datatypes/minecraft.js | 11 ++--- src/datatypes/varlong.js | 63 -------------------------- 3 files changed, 4 insertions(+), 140 deletions(-) delete mode 100644 src/datatypes/varlong.js diff --git a/src/datatypes/compiler-minecraft.js b/src/datatypes/compiler-minecraft.js index 3dd9483..75fd0b9 100644 --- a/src/datatypes/compiler-minecraft.js +++ b/src/datatypes/compiler-minecraft.js @@ -1,7 +1,7 @@ /* eslint-disable */ const UUID = require('uuid-1345') const minecraft = require('./minecraft') -const { Read, Write, SizeOf } = require('./varlong') +const [Read, Write, SizeOf] = [{}, {}, {}] /** * UUIDs @@ -116,74 +116,6 @@ Read.lnbt = ['native', minecraft.lnbt[0]] Write.lnbt = ['native', minecraft.lnbt[1]] SizeOf.lnbt = ['native', minecraft.lnbt[2]] -/** - * Bits - */ - -Read.bitflags = ['parametrizable', (compiler, { type, flags, shift, big }) => { - let fstr = JSON.stringify(flags) - if (Array.isArray(flags)) { - fstr = '{' - flags.map((v, k) => fstr += `"${v}": ${big ? 1n << BigInt(k) : 1 << k}` + (big ? 'n,' : ',')) - fstr += '}' - } else if (shift) { - fstr = '{' - for (const key in flags) fstr += `"${key}": ${1 << flags[key]},`; - fstr += '}' - } - return compiler.wrapCode(` - const { value: _value, size } = ${compiler.callType(type, 'offset')} - const value = { _value } - const flags = ${fstr} - for (const key in flags) { - value[key] = (_value & flags[key]) == flags[key] - } - return { value, size } - `.trim()) -}] - -Write.bitflags = ['parametrizable', (compiler, { type, flags, shift, big }) => { - let fstr = JSON.stringify(flags) - if (Array.isArray(flags)) { - fstr = '{' - flags.map((v, k) => fstr += `"${v}": ${big ? 1n << BigInt(k) : 1 << k}` + (big ? 'n,' : ',')) - fstr += '}' - } else if (shift) { - fstr = '{' - for (const key in flags) fstr += `"${key}": ${1 << flags[key]},`; - fstr += '}' - } - return compiler.wrapCode(` - const flags = ${fstr} - let val = value._value ${big ? '|| 0n' : ''} - for (const key in flags) { - if (value[key]) val |= flags[key] - } - return (ctx.${type})(val, buffer, offset) - `.trim()) -}] - -SizeOf.bitflags = ['parametrizable', (compiler, { type, flags, shift, big }) => { - let fstr = JSON.stringify(flags) - if (Array.isArray(flags)) { - fstr = '{' - flags.map((v, k) => fstr += `"${v}": ${big ? 1n << BigInt(k) : 1 << k}` + (big ? 'n,' : ',')) - fstr += '}' - } else if (shift) { - fstr = '{' - for (const key in flags) fstr += `"${key}": ${1 << flags[key]},`; - fstr += '}' - } - return compiler.wrapCode(` - const flags = ${fstr} - let val = value._value ${big ? '|| 0n' : ''} - for (const key in flags) { - if (value[key]) val |= flags[key] - } - return (ctx.${type})(val) - `.trim()) -}] - /** * Command Packet * - used for determining the size of the following enum diff --git a/src/datatypes/minecraft.js b/src/datatypes/minecraft.js index 1a9186d..117e5ff 100644 --- a/src/datatypes/minecraft.js +++ b/src/datatypes/minecraft.js @@ -1,14 +1,11 @@ -/* eslint-disable */ const nbt = require('prismarine-nbt') const UUID = require('uuid-1345') const protoLE = nbt.protos.little const protoLEV = nbt.protos.littleVarint -// TODO: deal with this: -const zigzag = require('prismarine-nbt/zigzag') function readUUID (buffer, offset) { - if (offset + 16 > buffer.length) { throw new PartialReadError() } + if (offset + 16 > buffer.length) { throw new Error('Reached end of buffer') } return { value: UUID.stringify(buffer.slice(offset, 16 + offset)), size: 16 @@ -65,7 +62,7 @@ function readEntityMetadata (buffer, offset, _ref) { const metadata = [] let item while (true) { - if (offset + 1 > buffer.length) throw new PartialReadError() + if (offset + 1 > buffer.length) throw new Error('Reached end of buffer') item = buffer.readUInt8(cursor) if (item === endVal) { return { @@ -159,7 +156,5 @@ module.exports = { lnbt: [readNbtLE, writeNbtLE, sizeOfNbtLE], entityMetadataLoop: [readEntityMetadata, writeEntityMetadata, sizeOfEntityMetadata], ipAddress: [readIpAddress, writeIpAddress, 4], - endOfArray: [readEndOfArray, writeEndOfArray, sizeOfEndOfArray], - zigzag32: zigzag.interpret.zigzag32, - zigzag64: zigzag.interpret.zigzag64 + endOfArray: [readEndOfArray, writeEndOfArray, sizeOfEndOfArray] } diff --git a/src/datatypes/varlong.js b/src/datatypes/varlong.js deleted file mode 100644 index 5e57ad7..0000000 --- a/src/datatypes/varlong.js +++ /dev/null @@ -1,63 +0,0 @@ -function sizeOfVarLong (value) { - if (typeof value.valueOf() === 'object') { - value = (BigInt(value[0]) << 32n) | BigInt(value[1]) - } else if (typeof value !== 'bigint') value = BigInt(value) - - let cursor = 0 - while (value > 127n) { - value >>= 7n - cursor++ - } - return cursor + 1 -} - -/** - * Reads a 64-bit VarInt as a BigInt - */ -function readVarLong (buffer, offset) { - let result = BigInt(0) - let shift = 0n - let cursor = offset - let size = 0 - - while (true) { - if (cursor + 1 > buffer.length) { throw new Error('unexpected buffer end') } - const b = buffer.readUInt8(cursor) - result |= (BigInt(b) & 0x7fn) << shift // Add the bits to our number, except MSB - cursor++ - if (!(b & 0x80)) { // If the MSB is not set, we return the number - size = cursor - offset - break - } - shift += 7n // we only have 7 bits, MSB being the return-trigger - if (shift > 63n) throw new Error(`varint is too big: ${shift}`) - } - - return { value: result, size } -} - -/** - * Writes a zigzag encoded 64-bit VarInt as a BigInt - */ -function writeVarLong (value, buffer, offset) { - // if an array, turn it into a BigInt - if (typeof value.valueOf() === 'object') { - value = BigInt.asIntN(64, (BigInt(value[0]) << 32n)) | BigInt(value[1]) - } else if (typeof value !== 'bigint') value = BigInt(value) - - let cursor = 0 - while (value > 127n) { // keep writing in 7 bit slices - const num = Number(value & 0xFFn) - buffer.writeUInt8(num | 0x80, offset + cursor) - cursor++ - value >>= 7n - } - buffer.writeUInt8(Number(value), offset + cursor) - return offset + cursor + 1 -} - -module.exports = { - Read: { varint64: ['native', readVarLong] }, - Write: { varint64: ['native', writeVarLong] }, - SizeOf: { varint64: ['native', sizeOfVarLong] } -} From 24d3200181c060162b04fb233fef6e0d6d1a93aa Mon Sep 17 00:00:00 2001 From: extremeheat Date: Mon, 9 Dec 2024 17:56:03 -0500 Subject: [PATCH 41/74] Add 1.21.40 login fields (#553) --- src/handshake/login.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/handshake/login.js b/src/handshake/login.js index 0a921fb..e25b15f 100644 --- a/src/handshake/login.js +++ b/src/handshake/login.js @@ -65,7 +65,11 @@ module.exports = (client, server, options) => { IsEditorMode: false, TrustedSkin: client.versionGreaterThanOrEqualTo('1.19.20') ? false : undefined, OverrideSkin: client.versionGreaterThanOrEqualTo('1.19.62') ? false : undefined, - CompatibleWithClientSideChunkGen: client.versionGreaterThanOrEqualTo('1.19.80') ? false : undefined + CompatibleWithClientSideChunkGen: client.versionGreaterThanOrEqualTo('1.19.80') ? false : undefined, + + MaxViewDistance: client.versionGreaterThanOrEqualTo('1.21.40') ? 0 : undefined, + MemoryTier: client.versionGreaterThanOrEqualTo('1.21.40') ? 0 : undefined, + PlatformType: client.versionGreaterThanOrEqualTo('1.21.40') ? 0 : undefined } const customPayload = options.skinData || {} payload = { ...payload, ...customPayload } From aa3dafa5f40660062018417636c1443656adacee Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Tue, 10 Dec 2024 04:40:12 +0100 Subject: [PATCH 42/74] Release 3.42.1 (#554) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- HISTORY.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 50ac34f..d85cbde 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.42.1 +* [Add 1.21.40 login fields (#553)](https://github.com/PrismarineJS/bedrock-protocol/commit/24d3200181c060162b04fb233fef6e0d6d1a93aa) (thanks @extremeheat) +* [Remove protodef varint types (#552)](https://github.com/PrismarineJS/bedrock-protocol/commit/347e303ce422bdb6f6dfd4cba57d7d3937214707) (thanks @extremeheat) + ## 3.42.0 * [1.21.50 support](https://github.com/PrismarineJS/bedrock-protocol/commit/1c0836bff03d50cb12a3e45763eac6c9f605e00c) (thanks @extremeheat) * [Dynamic compression & batch header (#544)](https://github.com/PrismarineJS/bedrock-protocol/commit/911e0e890febc00102cd1e5406731e66f7bad0ef) (thanks @LucienHH) diff --git a/package.json b/package.json index a87e71c..d0320da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.42.0", + "version": "3.42.1", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From dfcf5b2f1b6b0922973824ab620eec17855dfc0f Mon Sep 17 00:00:00 2001 From: poekcosimo <96430819+pokecosimo@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:56:20 +0100 Subject: [PATCH 43/74] Fix missing type serialization error (#557) --- src/transforms/serializer.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/transforms/serializer.js b/src/transforms/serializer.js index 91d4c97..8fffc42 100644 --- a/src/transforms/serializer.js +++ b/src/transforms/serializer.js @@ -37,7 +37,6 @@ function createProtocol (version) { const compiler = new ProtoDefCompiler() compiler.addTypesToCompile(protocol.types) compiler.addTypes(require('../datatypes/compiler-minecraft')) - compiler.addTypes(require('prismarine-nbt/zigzag').compiler) const compiledProto = compiler.compileProtoDefSync() return compiledProto @@ -47,7 +46,6 @@ function createProtocol (version) { function getProtocol (version) { const compiler = new ProtoDefCompiler() compiler.addTypes(require(join(__dirname, '../datatypes/compiler-minecraft'))) - compiler.addTypes(require('prismarine-nbt/zigzag').compiler) global.PartialReadError = require('protodef/src/utils').PartialReadError const compile = (compiler, file) => require(file)(compiler.native) From e7bb990aea9624944dc8c1fcb9daf09d2084cf0d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:20:53 +0000 Subject: [PATCH 44/74] Release 3.42.2 (#558) Update HISTORY.md --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index d85cbde..7182963 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.42.2 +* Fix missing type serialization error + ## 3.42.1 * [Add 1.21.40 login fields (#553)](https://github.com/PrismarineJS/bedrock-protocol/commit/24d3200181c060162b04fb233fef6e0d6d1a93aa) (thanks @extremeheat) * [Remove protodef varint types (#552)](https://github.com/PrismarineJS/bedrock-protocol/commit/347e303ce422bdb6f6dfd4cba57d7d3937214707) (thanks @extremeheat) diff --git a/package.json b/package.json index d0320da..4a380b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.42.1", + "version": "3.42.2", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From a37bc5054ef44664ab9f725d02e9dd6f1cb37b4f Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 2 Jan 2025 16:16:33 -0500 Subject: [PATCH 45/74] Add retry to tests --- package.json | 2 +- test/util.js | 7 ++++++- test/vanilla.js | 5 +++-- tools/genPacketDumps.js | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4a380b1..18573d6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "types": "index.d.ts", "scripts": { "build": "cd tools && node compileProtocol.js", - "test": "mocha --bail --exit", + "test": "mocha --retries 2 --bail --exit", "pretest": "npm run lint", "lint": "standard", "vanillaServer": "minecraft-bedrock-server --root tools --version", diff --git a/test/util.js b/test/util.js index 2876a67..3325863 100644 --- a/test/util.js +++ b/test/util.js @@ -5,7 +5,12 @@ const getPort = () => new Promise(resolve => { server.listen(0, '127.0.0.1') server.on('listening', () => { const { port } = server.address() - server.close(() => resolve(port)) + server.close(() => { + // Wait a bit for port to free as we try to bind right after freeing it + setTimeout(() => { + resolve(port) + }, 200) + }) }) }) diff --git a/test/vanilla.js b/test/vanilla.js index 7573368..73a5f44 100644 --- a/test/vanilla.js +++ b/test/vanilla.js @@ -8,8 +8,9 @@ async function test (version) { // const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + (version.includes('1.19') ? '1.18.30' : version)) // TODO: Fix prismarine-chunk // Start the server, wait for it to accept clients, throws on timeout - const port = await getPort() - const handle = await vanillaServer.startServerAndWait2(version, 1000 * 220, { 'server-port': port }) + const [port, v6] = [await getPort(), await getPort()] + console.log('Starting vanilla server', version, 'on port', port, v6) + const handle = await vanillaServer.startServerAndWait2(version, 1000 * 220, { 'server-port': port, 'server-portv6': v6 }) console.log('Started server') const client = new Client({ diff --git a/tools/genPacketDumps.js b/tools/genPacketDumps.js index 2e6420f..f0edbfe 100644 --- a/tools/genPacketDumps.js +++ b/tools/genPacketDumps.js @@ -24,7 +24,7 @@ async function dump (version, force = true) { const random = (Math.random() * 1000) | 0 const [port, v6] = [await getPort(), await getPort()] - console.log('Starting dump server', version) + console.log('Starting dump server', version, 'on port', port, v6) const handle = await vanillaServer.startServerAndWait2(version || CURRENT_VERSION, 1000 * 120, { 'server-port': port, 'server-portv6': v6 }) console.log('Started dump server', version) From a79be99c0f19becabc9847eac2fa2ce4344364d4 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 2 Jan 2025 18:53:50 -0500 Subject: [PATCH 46/74] Update ci.yml --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2055cc..150bd8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,5 +26,11 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + # Old versions of bedrock use old libssl that Ubuntu no longer ships with; need manual install + - name: (Linux) Install libssl 1.1 + if: runner.os == 'Linux' + run: | + wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb + sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb - run: npm install - run: npm test From 38dc5a256105a44786d5455570d5a130e64ef561 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 18 Jan 2025 02:51:08 -0500 Subject: [PATCH 47/74] Fix Server `maxPlayers` option (#565) --- index.d.ts | 2 +- src/server.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index ea1179a..cda2551 100644 --- a/index.d.ts +++ b/index.d.ts @@ -162,7 +162,7 @@ declare module 'bedrock-protocol' { constructor(options: Options) - listen(host?: string, port?: number): Promise + listen(): Promise close(disconnectReason?: string): Promise on(event: 'connect', cb: (client: Player) => void): any diff --git a/src/server.js b/src/server.js index 6d9aa79..4dc9852 100644 --- a/src/server.js +++ b/src/server.js @@ -118,8 +118,9 @@ class Server extends EventEmitter { return this.advertisement } - async listen (host = this.options.host, port = this.options.port) { - this.raknet = new this.RakServer({ host, port }, this) + async listen () { + const { host, port, maxPlayers } = this.options + this.raknet = new this.RakServer({ host, port, maxPlayers }, this) try { await this.raknet.listen() From cd9a31a435ab4ab0de6ff1d3e0fe67ffa631509e Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Sat, 18 Jan 2025 11:09:53 +0100 Subject: [PATCH 48/74] Release 3.42.3 (#567) --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 7182963..3bd4a54 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.42.3 +* [Fix Server `maxPlayers` option (#565)](https://github.com/PrismarineJS/bedrock-protocol/commit/38dc5a256105a44786d5455570d5a130e64ef561) (thanks @extremeheat) + ## 3.42.2 * Fix missing type serialization error diff --git a/package.json b/package.json index 18573d6..4d22728 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.42.2", + "version": "3.42.3", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 8e728255c7d87aacea483172ebc658d253a954d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 23:06:04 +0100 Subject: [PATCH 49/74] Bump mocha from 10.8.2 to 11.0.1 (#548) Bumps [mocha](https://github.com/mochajs/mocha) from 10.8.2 to 11.0.1. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v10.8.2...v11.0.1) --- updated-dependencies: - dependency-name: mocha dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d22728..424b2d0 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "bedrock-provider": "^2.0.0", "leveldb-zlib": "^1.0.1", "minecraft-bedrock-server": "^1.4.2", - "mocha": "^10.0.0", + "mocha": "^11.0.1", "protodef-yaml": "^1.1.0", "standard": "^17.0.0-2" }, From 75fa085e86708dc8d41b07c4eea1685419f005b4 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sun, 26 Jan 2025 23:06:36 +0100 Subject: [PATCH 50/74] node 22 (#568) --- .github/workflows/ci.yml | 2 +- .github/workflows/update-helper.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 150bd8a..4176a31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - node-version: [18.x] + node-version: [22.x] runs-on: ${{ matrix.os }} timeout-minutes: 14 steps: diff --git a/.github/workflows/update-helper.yml b/.github/workflows/update-helper.yml index 168dd04..d9380da 100644 --- a/.github/workflows/update-helper.yml +++ b/.github/workflows/update-helper.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@master with: - node-version: 18.0.0 + node-version: 22.0.0 - name: Install Github Actions helper run: npm i gh-helpers # The env vars contain the relevant trigger information, so we don't need to pass it From 0ed8e32be85f05926cd97d5f0317ed004ae5eefa Mon Sep 17 00:00:00 2001 From: Max <43801744+ItsMax123@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:02:04 -0500 Subject: [PATCH 51/74] Fix version feature handling (#572) * Replace unsupported version with next supported version * add validity check --------- Co-authored-by: extremeheat --- src/connection.js | 4 ++++ src/handshake/login.js | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/connection.js b/src/connection.js index eb01f7f..48073cf 100644 --- a/src/connection.js +++ b/src/connection.js @@ -28,18 +28,22 @@ class Connection extends EventEmitter { } versionLessThan (version) { + if (typeof version === 'string' && !Versions[version]) throw Error('Unknown version: ' + version) return this.options.protocolVersion < (typeof version === 'string' ? Versions[version] : version) } versionGreaterThan (version) { + if (typeof version === 'string' && !Versions[version]) throw Error('Unknown version: ' + version) return this.options.protocolVersion > (typeof version === 'string' ? Versions[version] : version) } versionGreaterThanOrEqualTo (version) { + if (typeof version === 'string' && !Versions[version]) throw Error('Unknown version: ' + version) return this.options.protocolVersion >= (typeof version === 'string' ? Versions[version] : version) } versionLessThanOrEqualTo (version) { + if (typeof version === 'string' && !Versions[version]) throw Error('Unknown version: ' + version) return this.options.protocolVersion <= (typeof version === 'string' ? Versions[version] : version) } diff --git a/src/handshake/login.js b/src/handshake/login.js index e25b15f..4523a50 100644 --- a/src/handshake/login.js +++ b/src/handshake/login.js @@ -67,9 +67,9 @@ module.exports = (client, server, options) => { OverrideSkin: client.versionGreaterThanOrEqualTo('1.19.62') ? false : undefined, CompatibleWithClientSideChunkGen: client.versionGreaterThanOrEqualTo('1.19.80') ? false : undefined, - MaxViewDistance: client.versionGreaterThanOrEqualTo('1.21.40') ? 0 : undefined, - MemoryTier: client.versionGreaterThanOrEqualTo('1.21.40') ? 0 : undefined, - PlatformType: client.versionGreaterThanOrEqualTo('1.21.40') ? 0 : undefined + MaxViewDistance: client.versionGreaterThanOrEqualTo('1.21.42') ? 0 : undefined, + MemoryTier: client.versionGreaterThanOrEqualTo('1.21.42') ? 0 : undefined, + PlatformType: client.versionGreaterThanOrEqualTo('1.21.42') ? 0 : undefined } const customPayload = options.skinData || {} payload = { ...payload, ...customPayload } From 2d7d32dfd18f0269831f71d8ecb968825dae7cdb Mon Sep 17 00:00:00 2001 From: Slauh! Date: Thu, 6 Feb 2025 10:54:38 -0800 Subject: [PATCH 52/74] Update API.md fix chat message handling (#575) --- docs/API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/API.md b/docs/API.md index b7b5722..d69c385 100644 --- a/docs/API.md +++ b/docs/API.md @@ -142,7 +142,7 @@ client.on('text', (packet) => { // names and as explained in the "Protocol doc" section below, fields are all case sensitive! client.on('add_player', (packet) => { client.queue('text', { - type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '', + type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '', filtered_message: '', message: `Hey, ${packet.username} just joined!` }) }) From eeb5e47e35f31cc571a9a8a491f5a89b27e637f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Papp?= <86970314+CreeperG16@users.noreply.github.com> Date: Wed, 12 Feb 2025 03:42:31 +0100 Subject: [PATCH 53/74] 1.21.60 support (#570) * Add support for ItemRegistryPacket (for shield item ID) * simplify * lint * internal test * update start_game handling * test: capture events rejections --------- Co-authored-by: extremeheat --- README.md | 2 +- index.d.ts | 2 +- src/client.js | 7 +++++-- src/connection.js | 12 ++++++++++-- src/options.js | 2 +- test/internal.js | 6 +++++- test/internal.test.js | 1 + 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 25971a1..cb2dcd4 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/index.d.ts b/index.d.ts index cda2551..581e87a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ import { Realm } from 'prismarine-realms' import { ServerDeviceCodeResponse } from 'prismarine-auth' declare module 'bedrock-protocol' { - type Version = '1.21.42' | '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' + type Version = '1.21.60' | '1.21.50' | '1.21.42' | '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' export interface Options { // The string version to start the client or server as diff --git a/src/client.js b/src/client.js index 2d798e6..472a777 100644 --- a/src/client.js +++ b/src/client.js @@ -61,7 +61,8 @@ class Client extends Connection { try { const mcData = require('minecraft-data')('bedrock_' + this.options.version) this.features = { - compressorInHeader: mcData.supportFeature('compressorInPacketHeader') + compressorInHeader: mcData.supportFeature('compressorInPacketHeader'), + itemRegistryPacket: mcData.supportFeature('itemRegistryPacket') } } catch (e) { throw new Error(`Unsupported version: '${this.options.version}', no data available`) @@ -241,7 +242,9 @@ class Client extends Connection { break case 'start_game': this.startGameData = pakData.params - this.startGameData.itemstates.forEach(state => { + // fallsthrough + case 'item_registry': // 1.21.60+ send itemstates in item_registry packet + pakData.params.itemstates?.forEach(state => { if (state.name === 'minecraft:shield') { this.serializer.proto.setVariable('ShieldItemID', state.runtime_id) this.deserializer.proto.setVariable('ShieldItemID', state.runtime_id) diff --git a/src/connection.js b/src/connection.js index 48073cf..f1e9051 100644 --- a/src/connection.js +++ b/src/connection.js @@ -70,9 +70,17 @@ class Connection extends EventEmitter { } } + _processOutbound (name, params) { + if (name === 'item_registry') { + this.updateItemPalette(params.itemstates) + } else if (name === 'start_game' && params.itemstates) { + this.updateItemPalette(params.itemstates) + } + } + write (name, params) { this.outLog?.(name, params) - if (name === 'start_game') this.updateItemPalette(params.itemstates) + this._processOutbound(name, params) const batch = new Framer(this) const packet = this.serializer.createPacketBuffer({ name, params }) batch.addEncodedPacket(packet) @@ -86,7 +94,7 @@ class Connection extends EventEmitter { queue (name, params) { this.outLog?.('Q <- ', name, params) - if (name === 'start_game') this.updateItemPalette(params.itemstates) + this._processOutbound(name, params) const packet = this.serializer.createPacketBuffer({ name, params }) if (name === 'level_chunk') { // Skip queue, send ASAP diff --git a/src/options.js b/src/options.js index dd42cdf..8eb5e0b 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.50' +const CURRENT_VERSION = '1.21.60' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) diff --git a/test/internal.js b/test/internal.js index 1003a87..70c7b11 100644 --- a/test/internal.js +++ b/test/internal.js @@ -63,7 +63,11 @@ async function startTest (version = CURRENT_VERSION, ok) { // client.queue('inventory_transaction', get('packets/inventory_transaction.json')) client.queue('player_list', get('packets/player_list.json')) client.queue('start_game', get('packets/start_game.json')) - client.queue('item_component', { entries: [] }) + if (client.versionLessThan('1.21.60')) { + client.queue('item_component', { entries: [] }) + } else { + client.queue('item_registry', get('packets/item_registry.json')) + } client.queue('set_spawn_position', get('packets/set_spawn_position.json')) client.queue('set_time', { time: 5433771 }) client.queue('set_difficulty', { difficulty: 1 }) diff --git a/test/internal.test.js b/test/internal.test.js index 1b6250c..271a7c5 100644 --- a/test/internal.test.js +++ b/test/internal.test.js @@ -3,6 +3,7 @@ const { timedTest } = require('./internal') const { testedVersions } = require('../src/options') const { sleep } = require('../src/datatypes/util') +require('events').captureRejections = true describe('internal client/server test', function () { const vcount = testedVersions.length From d4a9faf153f73387056119d329f5e39e074bc712 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Wed, 12 Feb 2025 04:08:50 +0100 Subject: [PATCH 54/74] Release 3.43.0 (#577) * Release 3.43.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 3bd4a54..9dfb2d4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.43.0 +* [1.21.60 support (#570)](https://github.com/PrismarineJS/bedrock-protocol/commit/eeb5e47e35f31cc571a9a8a491f5a89b27e637f1) (thanks @CreeperG16) +* [Fix version feature handling (#572)](https://github.com/PrismarineJS/bedrock-protocol/commit/0ed8e32be85f05926cd97d5f0317ed004ae5eefa) (thanks @ItsMax123) + ## 3.42.3 * [Fix Server `maxPlayers` option (#565)](https://github.com/PrismarineJS/bedrock-protocol/commit/38dc5a256105a44786d5455570d5a130e64ef561) (thanks @extremeheat) diff --git a/package.json b/package.json index 424b2d0..b5a34cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.42.3", + "version": "3.43.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 328785d8afa8bbd55f796e6fafa2da2357756e72 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 13 Feb 2025 15:36:33 -0500 Subject: [PATCH 55/74] Quicken tests --- src/options.js | 2 +- test/internal.js | 4 ++-- test/proxy.js | 8 ++++---- test/proxy.test.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/options.js b/src/options.js index 8eb5e0b..890d26a 100644 --- a/src/options.js +++ b/src/options.js @@ -8,7 +8,7 @@ const CURRENT_VERSION = '1.21.60' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) // Skip some low priority versions (middle major) on Github Actions to allow faster CI -const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10', '1.20.15', '1.20.30', '1.20.40', '1.20.50', '1.20.61', '1.20.71'] +const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10', '1.20.15', '1.20.30', '1.20.40', '1.20.50', '1.20.61', '1.20.71', '1.21.2', '1.21.20', '1.21.30', '1.21.42'] const testedVersions = process.env.CI ? Object.keys(Versions).filter(v => !skippedVersionsOnGithubCI.includes(v)) : Object.keys(Versions) const defaultOptions = { diff --git a/test/internal.js b/test/internal.js index 70c7b11..ffb403e 100644 --- a/test/internal.js +++ b/test/internal.js @@ -101,11 +101,11 @@ async function startTest (version = CURRENT_VERSION, ok) { loop = setInterval(() => { client.write('network_chunk_publisher_update', { coordinates: { x: 646, y: 130, z: 77 }, radius: 64 }) - }, 9500) + }, 6500) setTimeout(() => { client.write('play_status', { status: 'player_spawn' }) - }, 6000) + }, 3000) // Respond to tick synchronization packets client.on('tick_sync', (packet) => { diff --git a/test/proxy.js b/test/proxy.js index 345e89f..af443d7 100644 --- a/test/proxy.js +++ b/test/proxy.js @@ -22,12 +22,12 @@ function proxyTest (version, raknetBackend = 'raknet-native', timeout = 1000 * 4 console.debug('Client has authenticated') setTimeout(() => { client.disconnect('Hello world !') - }, 1000) // allow some time for client to connect + }, 500) // allow some time for client to connect }) }) console.debug('Server started', server.options.version) - await new Promise(resolve => setTimeout(resolve, 1000)) + await new Promise(resolve => setTimeout(resolve, 500)) const relay = new Relay({ version, @@ -46,7 +46,7 @@ function proxyTest (version, raknetBackend = 'raknet-native', timeout = 1000 * 4 await relay.listen() console.debug('Proxy started', server.options.version) - await new Promise(resolve => setTimeout(resolve, 1000)) + await new Promise(resolve => setTimeout(resolve, 500)) const client = createClient({ host: '127.0.0.1', port: CLIENT_PORT, version, username: 'Boat', offline: true, raknetBackend, skipPing: true }) console.debug('Client started') @@ -58,7 +58,7 @@ function proxyTest (version, raknetBackend = 'raknet-native', timeout = 1000 * 4 server.close() relay.close() console.log('✔ OK') - sleep(500).then(res) + sleep(200).then(res) }) }, timeout, () => { throw Error('timed out') }) } diff --git a/test/proxy.test.js b/test/proxy.test.js index 70ea5f1..27761ae 100644 --- a/test/proxy.test.js +++ b/test/proxy.test.js @@ -11,7 +11,7 @@ describe('proxies client/server', function () { it('proxies ' + version, async () => { console.debug(version) await proxyTest(version) - await sleep(1000) + await sleep(100) console.debug('Done', version) }) } From 47f342ca958ba87a7719783bd5c855cebdd4aa65 Mon Sep 17 00:00:00 2001 From: EntifiedOptics <137791538+EntifiedOptics@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:01:49 +0000 Subject: [PATCH 56/74] Fix server not correctly removing clients (#588) * Properly remove connection from clients list * Changed misname in onCloseConnection * Update server.js fix --------- Co-authored-by: JSbETms <137791538+JSbETms@users.noreply.github.com> Co-authored-by: extremeheat --- src/server.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/server.js b/src/server.js index 4dc9852..0f51bae 100644 --- a/src/server.js +++ b/src/server.js @@ -89,12 +89,10 @@ class Server extends EventEmitter { this.emit('connect', player) } - onCloseConnection = (inetAddr, reason) => { - this.conLog('Connection closed: ', inetAddr?.address, reason) - - delete this.clients[inetAddr]?.connection // Prevent close loop - this.clients[inetAddr?.address ?? inetAddr]?.close() - delete this.clients[inetAddr] + onCloseConnection = (conn, reason) => { + this.conLog('Connection closed: ', conn.address, reason) + this.clients[conn.address]?.close() + delete this.clients[conn.address] this.clientCount-- } From 9f11f219911fa53507937e1742411dce1f788ed4 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Wed, 19 Mar 2025 19:03:47 +0100 Subject: [PATCH 57/74] Release 3.43.1 (#592) * Release 3.43.1 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 9dfb2d4..63130ba 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.43.1 +* [Fix server not correctly removing clients (#588)](https://github.com/PrismarineJS/bedrock-protocol/commit/47f342ca958ba87a7719783bd5c855cebdd4aa65) (thanks @EntifiedOptics) + ## 3.43.0 * [1.21.60 support (#570)](https://github.com/PrismarineJS/bedrock-protocol/commit/eeb5e47e35f31cc571a9a8a491f5a89b27e637f1) (thanks @CreeperG16) * [Fix version feature handling (#572)](https://github.com/PrismarineJS/bedrock-protocol/commit/0ed8e32be85f05926cd97d5f0317ed004ae5eefa) (thanks @ItsMax123) diff --git a/package.json b/package.json index b5a34cc..3ef512d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.43.0", + "version": "3.43.1", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 065f41db8cfc8cbd8106bd9e376c899ec25f3f77 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 25 Mar 2025 23:38:56 -0400 Subject: [PATCH 58/74] 1.21.70 (#594) * Update options.js * Update README.md --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb2dcd4..7118e3a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index 890d26a..515b41f 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.60' +const CURRENT_VERSION = '1.21.70' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From d88309507d03c516bbfe6a0b5ab5a79dc4c10db0 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Wed, 26 Mar 2025 05:20:38 +0100 Subject: [PATCH 59/74] Release 3.44.0 (#595) * Release 3.44.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 63130ba..7520b5c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.44.0 +* [1.21.70 (#594)](https://github.com/PrismarineJS/bedrock-protocol/commit/065f41db8cfc8cbd8106bd9e376c899ec25f3f77) (thanks @CreeperG16) + ## 3.43.1 * [Fix server not correctly removing clients (#588)](https://github.com/PrismarineJS/bedrock-protocol/commit/47f342ca958ba87a7719783bd5c855cebdd4aa65) (thanks @EntifiedOptics) diff --git a/package.json b/package.json index 3ef512d..f4a8a57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.43.1", + "version": "3.44.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From b6b0bcdd70e565c26f021c675edac265c0665d81 Mon Sep 17 00:00:00 2001 From: LunaryNet2 Date: Tue, 1 Apr 2025 02:13:27 +0200 Subject: [PATCH 60/74] Update index.d.ts (#596) --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 581e87a..a0c70e3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ import { Realm } from 'prismarine-realms' import { ServerDeviceCodeResponse } from 'prismarine-auth' declare module 'bedrock-protocol' { - type Version = '1.21.60' | '1.21.50' | '1.21.42' | '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' + type Version = '1.21.70' | '1.21.60' | '1.21.50' | '1.21.42' | '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' export interface Options { // The string version to start the client or server as From e71fd513ddbd432983f221980080b61e11576965 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 8 May 2025 19:51:20 -0400 Subject: [PATCH 61/74] 1.21.80 (#602) --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7118e3a..53b6da5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index 515b41f..138e301 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.70' +const CURRENT_VERSION = '1.21.80' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From 29ba39343af38749c3e7aaa4c5dcd15ce45ab304 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Fri, 9 May 2025 02:19:26 +0200 Subject: [PATCH 62/74] Release 3.45.0 (#603) * Release 3.45.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 7520b5c..b0945c9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.45.0 +* [1.21.80 (#602)](https://github.com/PrismarineJS/bedrock-protocol/commit/e71fd513ddbd432983f221980080b61e11576965) (thanks @extremeheat) + ## 3.44.0 * [1.21.70 (#594)](https://github.com/PrismarineJS/bedrock-protocol/commit/065f41db8cfc8cbd8106bd9e376c899ec25f3f77) (thanks @CreeperG16) diff --git a/package.json b/package.json index f4a8a57..2938f34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.44.0", + "version": "3.45.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From e503c47c793377bf7272d116be3a755d4f1881eb Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 18 Jun 2025 20:14:38 -0400 Subject: [PATCH 63/74] Start work for 1.21.90 (#616) * 1.21.90 * update * remove 1.21.90 in ci --- src/client.js | 18 ++++++++++++++---- src/server.js | 3 ++- src/serverPlayer.js | 15 +++++++++++---- tools/compileProtocol.js | 3 +-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/client.js b/src/client.js index 472a777..e3af1d0 100644 --- a/src/client.js +++ b/src/client.js @@ -62,7 +62,8 @@ class Client extends Connection { const mcData = require('minecraft-data')('bedrock_' + this.options.version) this.features = { compressorInHeader: mcData.supportFeature('compressorInPacketHeader'), - itemRegistryPacket: mcData.supportFeature('itemRegistryPacket') + itemRegistryPacket: mcData.supportFeature('itemRegistryPacket'), + newLoginIdentityFields: mcData.supportFeature('newLoginIdentityFields') } } catch (e) { throw new Error(`Unsupported version: '${this.options.version}', no data available`) @@ -146,9 +147,18 @@ class Client extends Connection { ...this.accessToken // Mojang + Xbox JWT from auth ] - const encodedChain = JSON.stringify({ chain }) - - debug('Auth chain', chain) + let encodedChain + if (this.features.newLoginIdentityFields) { // 1.21.90+ + encodedChain = JSON.stringify({ + Certificate: JSON.stringify({ chain }), + // 0 = normal, 1 = ss, 2 = offline + AuthenticationType: this.options.offline ? 2 : 0, + Token: '' + }) + } else { + encodedChain = JSON.stringify({ chain }) + } + debug('Auth chain', encodedChain) this.write('login', { protocol_version: this.options.protocolVersion, diff --git a/src/server.js b/src/server.js index 0f51bae..0b43fd2 100644 --- a/src/server.js +++ b/src/server.js @@ -33,7 +33,8 @@ class Server extends EventEmitter { try { const mcData = require('minecraft-data')('bedrock_' + version) this.features = { - compressorInHeader: mcData.supportFeature('compressorInPacketHeader') + compressorInHeader: mcData.supportFeature('compressorInPacketHeader'), + newLoginIdentityFields: mcData.supportFeature('newLoginIdentityFields') } } catch (e) { throw new Error(`Unsupported version: '${version}', no data available`) diff --git a/src/serverPlayer.js b/src/serverPlayer.js index b7ef02d..2e8ea77 100644 --- a/src/serverPlayer.js +++ b/src/serverPlayer.js @@ -78,11 +78,18 @@ class Player extends Connection { // Parse login data const tokens = body.params.tokens - const authChain = JSON.parse(tokens.identity) - const skinChain = tokens.client - try { - var { key, userData, skinData } = this.decodeLoginJWT(authChain.chain, skinChain) // eslint-disable-line + const skinChain = tokens.client + const authChain = JSON.parse(tokens.identity) + let chain + if (authChain.Certificate) { // 1.21.90+ + chain = JSON.parse(authChain.Certificate).chain + } else if (authChain.chain) { + chain = authChain.chain + } else { + throw new Error('Invalid login packet: missing chain or Certificate') + } + var { key, userData, skinData } = this.decodeLoginJWT(chain, skinChain) // eslint-disable-line } catch (e) { debug(this.address, e) this.disconnect('Server authentication error') diff --git a/tools/compileProtocol.js b/tools/compileProtocol.js index dcf6545..a7c3aa0 100644 --- a/tools/compileProtocol.js +++ b/tools/compileProtocol.js @@ -15,7 +15,6 @@ function createProtocol (version) { const compiler = new ProtoDefCompiler() const protocol = mcData('bedrock_' + version).protocol.types compiler.addTypes(require('../src/datatypes/compiler-minecraft')) - compiler.addTypes(require('prismarine-nbt/zigzag').compiler) compiler.addTypesToCompile(protocol) fs.writeFileSync('./read.js', 'module.exports = ' + compiler.readCompiler.generate().replace('() =>', 'native =>')) @@ -39,7 +38,7 @@ require('minecraft-data/bin/generate_data') // If no argument, build everything if (!process.argv[2]) { - convert('latest') + convert('bedrock', 'latest') for (const version of versions) { main(version) } From c66cdd3d62d2fa9c581693d8c70d7b41f355b63e Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 18 Jun 2025 21:31:21 -0400 Subject: [PATCH 64/74] 1.21.90 (#617) * 1.21.90 * Update README.md --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 53b6da5..31c70b0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80, 1.21.90 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index 138e301..a3d8f32 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.80' +const CURRENT_VERSION = '1.21.90' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From 80751d58a7be03ad1c7692f6af4705e819e38d53 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Thu, 19 Jun 2025 03:51:20 +0200 Subject: [PATCH 65/74] Release 3.46.0 (#618) * Release 3.46.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index b0945c9..17f6406 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.46.0 +* [1.21.90 support (#617)](https://github.com/PrismarineJS/bedrock-protocol/commit/c66cdd3d62d2fa9c581693d8c70d7b41f355b63e) (thanks @CreeperG16) + ## 3.45.0 * [1.21.80 (#602)](https://github.com/PrismarineJS/bedrock-protocol/commit/e71fd513ddbd432983f221980080b61e11576965) (thanks @extremeheat) diff --git a/package.json b/package.json index 2938f34..41b184f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.45.0", + "version": "3.46.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 14daa2d95aac90ffcc7b42d625e270020ec2f162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Papp?= <86970314+CreeperG16@users.noreply.github.com> Date: Fri, 4 Jul 2025 21:47:12 +0100 Subject: [PATCH 66/74] 1.21.93 support (#623) --- README.md | 2 +- index.d.ts | 2 +- src/options.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 31c70b0..6a4088e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80, 1.21.90 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80, 1.21.90, 1.21.93 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/index.d.ts b/index.d.ts index a0c70e3..3f4a571 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ import { Realm } from 'prismarine-realms' import { ServerDeviceCodeResponse } from 'prismarine-auth' declare module 'bedrock-protocol' { - type Version = '1.21.70' | '1.21.60' | '1.21.50' | '1.21.42' | '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' + type Version = '1.21.93' | '1.21.90' | '1.21.80' | '1.21.70' | '1.21.60' | '1.21.50' | '1.21.42' | '1.21.30' | '1.21.2' | '1.21.0' | '1.20.80' | '1.20.71' | '1.20.61' | '1.20.50' | '1.20.40' | '1.20.30' | '1.20.10' | '1.20.0' | '1.19.80' | '1.19.70' | '1.19.63' | '1.19.62' | '1.19.60' | '1.19.51' | '1.19.50' | '1.19.41' | '1.19.40' | '1.19.31' | '1.19.30' | '1.19.22' | '1.19.21' | '1.19.20' | '1.19.11' | '1.19.10' | '1.19.2' | '1.19.1' | '1.18.31' | '1.18.30' | '1.18.12' | '1.18.11' | '1.18.10' | '1.18.2' | '1.18.1' | '1.18.0' | '1.17.41' | '1.17.40' | '1.17.34' | '1.17.30' | '1.17.11' | '1.17.10' | '1.17.0' | '1.16.220' | '1.16.210' | '1.16.201' export interface Options { // The string version to start the client or server as diff --git a/src/options.js b/src/options.js index a3d8f32..35ba338 100644 --- a/src/options.js +++ b/src/options.js @@ -3,12 +3,12 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.90' +const CURRENT_VERSION = '1.21.93' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) // Skip some low priority versions (middle major) on Github Actions to allow faster CI -const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10', '1.20.15', '1.20.30', '1.20.40', '1.20.50', '1.20.61', '1.20.71', '1.21.2', '1.21.20', '1.21.30', '1.21.42'] +const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10', '1.20.15', '1.20.30', '1.20.40', '1.20.50', '1.20.61', '1.20.71', '1.21.2', '1.21.20', '1.21.30', '1.21.42', '1.21.90'] const testedVersions = process.env.CI ? Object.keys(Versions).filter(v => !skippedVersionsOnGithubCI.includes(v)) : Object.keys(Versions) const defaultOptions = { From 6f06a8996e885d45278c12f9320de22ff04633a2 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Fri, 4 Jul 2025 22:48:07 +0200 Subject: [PATCH 67/74] Release 3.47.0 (#625) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 17f6406..47245a9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.47.0 +* [1.21.93 support (#623)](https://github.com/PrismarineJS/bedrock-protocol/commit/14daa2d95aac90ffcc7b42d625e270020ec2f162) (thanks @CreeperG16) + ## 3.46.0 * [1.21.90 support (#617)](https://github.com/PrismarineJS/bedrock-protocol/commit/c66cdd3d62d2fa9c581693d8c70d7b41f355b63e) (thanks @CreeperG16) diff --git a/package.json b/package.json index 41b184f..2f9c73e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.46.0", + "version": "3.47.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 06fb3de3a0023d03201dbcee7e9178c269462766 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 6 Aug 2025 14:05:20 -0400 Subject: [PATCH 68/74] 1.21.100 (#632) * Update options.js * Update README.md --- README.md | 2 +- src/options.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6a4088e..2ea5282 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80, 1.21.90, 1.21.93 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80, 1.21.90, 1.21.93, 1.21.100 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index 35ba338..ee85da3 100644 --- a/src/options.js +++ b/src/options.js @@ -3,12 +3,12 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.93' +const CURRENT_VERSION = '1.21.100' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) // Skip some low priority versions (middle major) on Github Actions to allow faster CI -const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10', '1.20.15', '1.20.30', '1.20.40', '1.20.50', '1.20.61', '1.20.71', '1.21.2', '1.21.20', '1.21.30', '1.21.42', '1.21.90'] +const skippedVersionsOnGithubCI = ['1.16.210', '1.17.10', '1.17.30', '1.18.11', '1.19.10', '1.19.20', '1.19.30', '1.19.40', '1.19.50', '1.19.60', '1.19.63', '1.19.70', '1.20.10', '1.20.15', '1.20.30', '1.20.40', '1.20.50', '1.20.61', '1.20.71', '1.21.2', '1.21.20', '1.21.30', '1.21.42', '1.21.50', '1.21.60', '1.21.70', '1.21.80', '1.21.90'] const testedVersions = process.env.CI ? Object.keys(Versions).filter(v => !skippedVersionsOnGithubCI.includes(v)) : Object.keys(Versions) const defaultOptions = { From 6c659feb5d54bbeb029cef02180e7470c24f1303 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Wed, 6 Aug 2025 20:16:25 +0200 Subject: [PATCH 69/74] Release 3.48.0 (#633) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 47245a9..a7d04e1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.48.0 +* [1.21.100 (#632)](https://github.com/PrismarineJS/bedrock-protocol/commit/06fb3de3a0023d03201dbcee7e9178c269462766) (thanks @extremeheat) + ## 3.47.0 * [1.21.93 support (#623)](https://github.com/PrismarineJS/bedrock-protocol/commit/14daa2d95aac90ffcc7b42d625e270020ec2f162) (thanks @CreeperG16) diff --git a/package.json b/package.json index 2f9c73e..3097b3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.47.0", + "version": "3.48.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 6b1474d2c6f93b47dee9d4816de59579f82ed5a9 Mon Sep 17 00:00:00 2001 From: TSL534 <166989673+TSL534@users.noreply.github.com> Date: Sun, 10 Aug 2025 07:47:18 +0200 Subject: [PATCH 70/74] Update login client skinData (#635) * Update for the Skin Data in the Login system * Fix for CI * CI Fix2 * Fixed comments again for CI * Update login.js --------- Co-authored-by: extremeheat --- src/handshake/login.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/handshake/login.js b/src/handshake/login.js index 4523a50..7c5ed4c 100644 --- a/src/handshake/login.js +++ b/src/handshake/login.js @@ -47,19 +47,20 @@ module.exports = (client, server, options) => { GameVersion: options.version || '1.16.201', GuiScale: -1, LanguageCode: 'en_GB', // TODO locale + GraphicsMode: 1, // 1:simple, 2:fancy, 3:advanced, 4:ray_traced PlatformOfflineId: '', PlatformOnlineId: '', // chat // PlayFabID is the PlayFab ID produced for the skin. PlayFab is the company that hosts the Marketplace, // skins and other related features from the game. This ID is the ID of the skin used to store the skin - // inside of PlayFab. - PlayFabId: nextUUID().replace(/-/g, '').slice(0, 16), // 1.16.210 + // inside of PlayFab.The playfab ID is always lowercased. + PlayFabId: nextUUID().replace(/-/g, '').slice(0, 16).toLowerCase(), // 1.16.210 SelfSignedId: nextUUID(), ServerAddress: `${options.host}:${options.port}`, - ThirdPartyName: client.profile.name, - ThirdPartyNameOnly: false, + ThirdPartyName: client.profile.name, // Gamertag + ThirdPartyNameOnly: client.versionGreaterThanOrEqualTo('1.21.90') ? undefined : false, UIProfile: 0, IsEditorMode: false, From 0b9c49fedcb4e0e9bdc9e1c6b1fc251884d67e4a Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Sun, 10 Aug 2025 08:31:46 +0200 Subject: [PATCH 71/74] Release 3.48.1 (#638) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index a7d04e1..8f93899 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## 3.48.1 +* [Update login client skinData (#635)](https://github.com/PrismarineJS/bedrock-protocol/commit/6b1474d2c6f93b47dee9d4816de59579f82ed5a9) (thanks @TSL534) + ## 3.48.0 * [1.21.100 (#632)](https://github.com/PrismarineJS/bedrock-protocol/commit/06fb3de3a0023d03201dbcee7e9178c269462766) (thanks @extremeheat) diff --git a/package.json b/package.json index 3097b3d..16874af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.48.0", + "version": "3.48.1", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts", From 407756b93880cdda4fdbff194fc4163ceedf4e82 Mon Sep 17 00:00:00 2001 From: thejfkvis <210196137+thejfkvis@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:51:53 -0400 Subject: [PATCH 72/74] Skin Data Changes (#647) --- src/handshake/login.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/handshake/login.js b/src/handshake/login.js index 7c5ed4c..8a2830d 100644 --- a/src/handshake/login.js +++ b/src/handshake/login.js @@ -36,7 +36,6 @@ module.exports = (client, server, options) => { client.createClientUserChain = (privateKey) => { let payload = { ...skinData, - SkinGeometryDataEngineVersion: client.versionGreaterThanOrEqualTo('1.17.30') ? '' : undefined, ClientRandomId: Date.now(), CurrentInputMode: 1, From b48518a6e79e72101fe7136433cbd6277339fc5c Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 1 Oct 2025 20:52:10 -0400 Subject: [PATCH 73/74] 1.21.111 (#649) --- README.md | 2 +- src/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ea5282..5e3add2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Minecraft Bedrock Edition (aka MCPE) protocol library, supporting authentication ## 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80, 1.21.90, 1.21.93, 1.21.100 + - 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, 1.19.21, 1.19.30, 1.19.40, 1.19.41, 1.19.50, 1.19.60, 1.19.62, 1.19.63, 1.19.70, 1.19.80, 1.20.0, 1.20.10, 1.20.30, 1.20.40, 1.20.50, 1.20.61, 1.20.71, 1.20.80, 1.21.0, 1.21.2, 1.21.21, 1.21.30, 1.21.42, 1.21.50, 1.21.60, 1.21.70, 1.21.80, 1.21.90, 1.21.93, 1.21.100, 1.21.111 - Parse and serialize packets as JavaScript objects - Automatically respond to keep-alive packets - [Proxy and mitm connections](docs/API.md#proxy-docs) diff --git a/src/options.js b/src/options.js index ee85da3..6e27dbe 100644 --- a/src/options.js +++ b/src/options.js @@ -3,7 +3,7 @@ const mcData = require('minecraft-data') // Minimum supported version (< will be kicked) const MIN_VERSION = '1.16.201' // Currently supported verson. Note, clients with newer versions can still connect as long as data is in minecraft-data -const CURRENT_VERSION = '1.21.100' +const CURRENT_VERSION = '1.21.111' const Versions = Object.fromEntries(mcData.versions.bedrock.filter(e => e.releaseType === 'release').map(e => [e.minecraftVersion, e.version])) From fa6acab0f3b92d3a0e3a4f7f0b48d2320c23f949 Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Thu, 2 Oct 2025 03:21:34 +0200 Subject: [PATCH 74/74] Release 3.49.0 (#650) * Release 3.49.0 * Update HISTORY.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: extremeheat --- HISTORY.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 8f93899..799d0a9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 3.49.0 +* [1.21.111 (#649)](https://github.com/PrismarineJS/bedrock-protocol/commit/b48518a6e79e72101fe7136433cbd6277339fc5c) (thanks @Slauh) +* [Skin Data Changes (#647)](https://github.com/PrismarineJS/bedrock-protocol/commit/407756b93880cdda4fdbff194fc4163ceedf4e82) (thanks @thejfkvis) + ## 3.48.1 * [Update login client skinData (#635)](https://github.com/PrismarineJS/bedrock-protocol/commit/6b1474d2c6f93b47dee9d4816de59579f82ed5a9) (thanks @TSL534) diff --git a/package.json b/package.json index 16874af..6301be0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bedrock-protocol", - "version": "3.48.1", + "version": "3.49.0", "description": "Minecraft Bedrock Edition protocol library", "main": "index.js", "types": "index.d.ts",