From 330f5e2494b5cbb41fde2b5c6bd4dfd94ab5cecf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 7 Oct 2025 20:30:16 +0000 Subject: [PATCH 1/6] Update to version 1.21.10 --- .github/workflows/ci.yml | 3 +++ docs/README.md | 2 +- src/version.js | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c80125a..adca2bb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,5 +56,8 @@ jobs: distribution: 'adopt' - name: Install dependencies run: npm install + - run: cd node_modules && cd minecraft-data && mv minecraft-data minecraft-data-old && git clone -b pc_1_21_10 https://github.com/PrismarineJS/minecraft-data --depth 1 && node bin/generate_data.js + - run: curl -o node_modules/protodef/src/serializer.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/serializer.js && curl -o node_modules/protodef/src/compiler.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/compiler.js + - name: Run tests run: npm run mochaTest -- -g ${{ matrix.mcVersion }}v diff --git a/docs/README.md b/docs/README.md index 028e05bf..be799db9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,7 +18,7 @@ Parse and serialize minecraft packets, plus authentication and encryption. 1.15 (1.15, 1.15.1, 1.15.2), 1.16 (20w13b, 20w14a, 1.16-rc1, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5), 1.17 (21w07a, 1.17, 1.17.1), 1.18 (1.18, 1.18.1 and 1.18.2), 1.19 (1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4), 1.20 (1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6), - 1.21, 1.21.1, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.8 + 1.21, 1.21.1, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.8, 1.21.10 * Parses all packets and emits events with packet fields as JavaScript diff --git a/src/version.js b/src/version.js index 7525bd70..85aa4907 100644 --- a/src/version.js +++ b/src/version.js @@ -1,6 +1,6 @@ 'use strict' module.exports = { - defaultVersion: '1.21.8', - supportedVersions: ['1.7', '1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1', '1.21.3', '1.21.4', '1.21.5', '1.21.6', '1.21.8'] + defaultVersion: '1.21.10', + supportedVersions: ['1.7', '1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1', '1.21.3', '1.21.4', '1.21.5', '1.21.6', '1.21.8', '1.21.10'] } From ab9aecf8a9416ba0260a39d47ad5f3c187e1092e Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 7 Oct 2025 20:59:31 -0400 Subject: [PATCH 2/6] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index adca2bb9..087d20a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: distribution: 'adopt' - name: Install dependencies run: npm install - - run: cd node_modules && cd minecraft-data && mv minecraft-data minecraft-data-old && git clone -b pc_1_21_10 https://github.com/PrismarineJS/minecraft-data --depth 1 && node bin/generate_data.js + - run: cd node_modules && cd minecraft-data && mv minecraft-data minecraft-data-old && git clone -b pc-1_21_10 https://github.com/PrismarineJS/minecraft-data --depth 1 && node bin/generate_data.js - run: curl -o node_modules/protodef/src/serializer.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/serializer.js && curl -o node_modules/protodef/src/compiler.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/compiler.js - name: Run tests From 39689b1acc6169353286cd027d6bae89d2aac951 Mon Sep 17 00:00:00 2001 From: SuperGamerTron Date: Wed, 14 Jan 2026 10:14:57 -0700 Subject: [PATCH 3/6] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 087d20a1..afb7dc51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: distribution: 'adopt' - name: Install dependencies run: npm install - - run: cd node_modules && cd minecraft-data && mv minecraft-data minecraft-data-old && git clone -b pc-1_21_10 https://github.com/PrismarineJS/minecraft-data --depth 1 && node bin/generate_data.js + - run: cd node_modules && cd minecraft-data && mv minecraft-data minecraft-data-old && git clone -b pc-1_21_10 https://github.com/SuperGamerTron/minecraft-data --depth 1 && node bin/generate_data.js - run: curl -o node_modules/protodef/src/serializer.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/serializer.js && curl -o node_modules/protodef/src/compiler.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/compiler.js - name: Run tests From fd843338fcf79f5d061d8ac3693a70c6ef0e864f Mon Sep 17 00:00:00 2001 From: SuperGamerTron Date: Wed, 14 Jan 2026 10:15:07 -0700 Subject: [PATCH 4/6] Update packetTest.js types --- test/packetTest.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/packetTest.js b/test/packetTest.js index 81ee1695..42b2914b 100644 --- a/test/packetTest.js +++ b/test/packetTest.js @@ -415,6 +415,34 @@ const values = { RecipeBookSetting: { open: false, filtering: false + }, + lpVec3: { x: 0, y: 0, z: 0 }, + DebugSubscriptionDataType: 0, + DebugSubscriptionUpdate: { + type: 0 + }, + DebugSubscriptionEvent: { + type: 0 + }, + RespawnData: { + globalPos: { + dimensionName: 'minecraft:overworld', + location: { x: 0, y: 64, z: 0 } + }, + yaw: 0, + pitch: 0 + }, + GlobalPos: { + dimensionName: 'minecraft:overworld', + location: { x: 0, y: 64, z: 0 } + }, + ExplosionParticleInfo: { + particle: { + particleId: 0, + data: null + }, + speed: 0, + scaling: 0 } } From 3f3d341f7df9577240c140baed253bbbf7b505c5 Mon Sep 17 00:00:00 2001 From: SuperGamerTron Date: Wed, 14 Jan 2026 10:15:21 -0700 Subject: [PATCH 5/6] Handle code_of_conduct packets --- src/client/play.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/play.js b/src/client/play.js index 4dc1c313..71ad739f 100644 --- a/src/client/play.js +++ b/src/client/play.js @@ -56,6 +56,9 @@ module.exports = function (client, options) { client.once('select_known_packs', () => { client.write('select_known_packs', { packs: [] }) }) + client.once('code_of_conduct', () => { + client.write('accept_code_of_conduct', {}) + }) // Server should send finish_configuration on its own right after sending the client a dimension codec // for login (that has data about world height, world gen, etc) after getting a login success from client client.once('finish_configuration', () => { From f0a096555631e496819f6db3789a6966cc62d66b Mon Sep 17 00:00:00 2001 From: SuperGamerTron Date: Wed, 14 Jan 2026 10:15:57 -0700 Subject: [PATCH 6/6] Implement lpVec3 --- src/datatypes/compiler-minecraft.js | 9 ++- src/datatypes/lpVec3.js | 117 ++++++++++++++++++++++++++++ src/datatypes/minecraft.js | 4 +- 3 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 src/datatypes/lpVec3.js diff --git a/src/datatypes/compiler-minecraft.js b/src/datatypes/compiler-minecraft.js index 9068641a..8a252a7c 100644 --- a/src/datatypes/compiler-minecraft.js +++ b/src/datatypes/compiler-minecraft.js @@ -70,7 +70,8 @@ if (n !== 0) { return { value: { ${opts.otherwise.name}: set }, size: accSize } } `.trim()) - }] + }], + lpVec3: ['native', minecraft.lpVec3[0]] }, Write: { varlong: ['native', minecraft.varlong[1]], @@ -135,7 +136,8 @@ if (${baseName} != null) { } return offset `.trim()) - }] + }], + lpVec3: ['native', minecraft.lpVec3[1]] }, SizeOf: { varlong: ['native', minecraft.varlong[2]], @@ -194,6 +196,7 @@ if (${baseName} != null) { } return size `.trim()) - }] + }], + lpVec3: ['native', minecraft.lpVec3[2]] } } diff --git a/src/datatypes/lpVec3.js b/src/datatypes/lpVec3.js new file mode 100644 index 00000000..fd049dc8 --- /dev/null +++ b/src/datatypes/lpVec3.js @@ -0,0 +1,117 @@ +const [readVarInt, writeVarInt, sizeOfVarInt] = require('protodef').types.varint + +// Adapted from https://github.com/extremeheat/extracted_minecraft_data/blob/client1.21.10/client/net/minecraft/network/LpVec3.java + +const DATA_BITS_MASK = 32767 +const MAX_QUANTIZED_VALUE = 32766.0 +const SCALE_BITS = 2 +const SCALE_BITS_MASK = 3 +const CONTINUATION_FLAG = 4 +const X_OFFSET = 3 +const Y_OFFSET = 18 +const Z_OFFSET = 33 +const ABS_MAX_VALUE = 1.7179869183e10 +const ABS_MIN_VALUE = 3.051944088384301e-5 + +function hasContinuationBit (a) { + return (a & CONTINUATION_FLAG) === CONTINUATION_FLAG +} + +function sanitize (value) { + if (Number.isNaN(value)) return 0.0 + return Math.max(-ABS_MAX_VALUE, Math.min(value, ABS_MAX_VALUE)) +} + +function pack (value) { + return BigInt(Math.round((value * 0.5 + 0.5) * MAX_QUANTIZED_VALUE)) +} + +function unpack (bits) { + const masked = Number(bits & BigInt(DATA_BITS_MASK)) + const clamped = Math.min(masked, MAX_QUANTIZED_VALUE) + return (clamped * 2.0) / MAX_QUANTIZED_VALUE - 1.0 +} + +function readLpVec3 (buffer, offset) { + if (offset + 1 > buffer.length) throw new Error('Unexpected end while reading LpVec3') + const a = buffer.readUInt8(offset) + + if (a === 0) { + return { value: { x: 0, y: 0, z: 0 }, size: 1 } + } + + if (offset + 6 > buffer.length) throw new Error('Unexpected end while reading LpVec3') + const b = buffer.readUInt8(offset + 1) + const c = buffer.readUInt32LE(offset + 2) + + const packed = (BigInt(c >>> 0) << 16n) | (BigInt(b & 0xff) << 8n) | BigInt(a & 0xff) + + let scale = BigInt(a & SCALE_BITS_MASK) + let totalSize = 6 + + if (hasContinuationBit(a)) { + const dRes = readVarInt(buffer, offset + 6) + scale |= (BigInt(dRes.value >>> 0) << BigInt(SCALE_BITS)) + totalSize = 6 + dRes.size + } + + const x = unpack(packed >> BigInt(X_OFFSET)) * Number(scale) + const y = unpack(packed >> BigInt(Y_OFFSET)) * Number(scale) + const z = unpack(packed >> BigInt(Z_OFFSET)) * Number(scale) + + return { value: { x, y, z }, size: totalSize } +} + +function writeLpVec3 (value, buffer, offset) { + const x = sanitize(value.x) + const y = sanitize(value.y) + const z = sanitize(value.z) + + const max = Math.max(Math.abs(x), Math.abs(y), Math.abs(z)) + + if (max < ABS_MIN_VALUE) { + buffer.writeUInt8(0, offset) + return offset + 1 + } + + const scale = BigInt(Math.ceil(max)) + const needsContinuation = (scale & BigInt(SCALE_BITS_MASK)) !== scale + + const scaleByte = needsContinuation ? ((scale & BigInt(SCALE_BITS_MASK)) | BigInt(CONTINUATION_FLAG)) : scale + const scaleNum = Number(scale) + + const packedX = pack(x / scaleNum) << BigInt(X_OFFSET) + const packedY = pack(y / scaleNum) << BigInt(Y_OFFSET) + const packedZ = pack(z / scaleNum) << BigInt(Z_OFFSET) + + const packed = scaleByte | packedX | packedY | packedZ + + buffer.writeUInt8(Number(packed) & 0xff, offset) + buffer.writeUInt8(Number((packed >> 8n) & 0xffn) & 0xff, offset + 1) + buffer.writeUInt32LE(Number((packed >> 16n) & 0xffffffffn) >>> 0, offset + 2) + + if (needsContinuation) { + return writeVarInt(Number(scale >> BigInt(SCALE_BITS)) >>> 0, buffer, offset + 6) + } + return offset + 6 +} + +function sizeOfLpVec3 (value) { + const x = sanitize(value.x) + const y = sanitize(value.y) + const z = sanitize(value.z) + + const max = Math.max(Math.abs(x), Math.abs(y), Math.abs(z)) + + if (max < ABS_MIN_VALUE) return 1 + + const scale = BigInt(Math.ceil(max)) + const needsContinuation = (scale & BigInt(SCALE_BITS_MASK)) !== scale + + if (needsContinuation) { + return 6 + sizeOfVarInt(Number(scale >> BigInt(SCALE_BITS)) >>> 0) + } + return 6 +} + +module.exports = [readLpVec3, writeLpVec3, sizeOfLpVec3] diff --git a/src/datatypes/minecraft.js b/src/datatypes/minecraft.js index 09e90355..83ab50e8 100644 --- a/src/datatypes/minecraft.js +++ b/src/datatypes/minecraft.js @@ -4,6 +4,7 @@ const nbt = require('prismarine-nbt') const UUID = require('uuid-1345') const zlib = require('zlib') const [readVarInt, writeVarInt, sizeOfVarInt] = require('protodef').types.varint +const [readLpVec3, writeLpVec3, sizeOfLpVec3] = require('./lpVec3') module.exports = { varlong: [readVarLong, writeVarLong, sizeOfVarLong], @@ -11,7 +12,8 @@ module.exports = { compressedNbt: [readCompressedNbt, writeCompressedNbt, sizeOfCompressedNbt], restBuffer: [readRestBuffer, writeRestBuffer, sizeOfRestBuffer], entityMetadataLoop: [readEntityMetadata, writeEntityMetadata, sizeOfEntityMetadata], - topBitSetTerminatedArray: [readTopBitSetTerminatedArray, writeTopBitSetTerminatedArray, sizeOfTopBitSetTerminatedArray] + topBitSetTerminatedArray: [readTopBitSetTerminatedArray, writeTopBitSetTerminatedArray, sizeOfTopBitSetTerminatedArray], + lpVec3: [readLpVec3, writeLpVec3, sizeOfLpVec3] } const PartialReadError = require('protodef').utils.PartialReadError