From 22e44423db8534f4064c86aad6c9273f17d1a386 Mon Sep 17 00:00:00 2001 From: E x o t i c Date: Mon, 9 Mar 2026 15:11:35 -0400 Subject: [PATCH 1/6] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ff0ed80..3f92cd1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Legacy Cross Play +# I AM AWARE THE PROJECT IS BROKEN RIGHT NOW, THE CLIENT UPDATED AND IM WORNING ON A FIX. **This project allows Legacy Console Edition clients to join a vanilla 1.8 Java Edition server!** ![](https://raw.githubusercontent.com/DeveloperExotic/LegacyCrossPlay/refs/heads/main/.assets/lce1.png) From 28f8ce5679bc6a1ce78b769cd9843ea4c76a1d17 Mon Sep 17 00:00:00 2001 From: E x o t i c Date: Mon, 9 Mar 2026 16:51:10 -0400 Subject: [PATCH 2/6] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3f92cd1..48024fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Legacy Cross Play # I AM AWARE THE PROJECT IS BROKEN RIGHT NOW, THE CLIENT UPDATED AND IM WORNING ON A FIX. +# Any questions, need help? Join my server: https://discord.gg/cb9rs9yfDm **This project allows Legacy Console Edition clients to join a vanilla 1.8 Java Edition server!** ![](https://raw.githubusercontent.com/DeveloperExotic/LegacyCrossPlay/refs/heads/main/.assets/lce1.png) From 7664d06f02662230241b68cc7001728ea329c2e8 Mon Sep 17 00:00:00 2001 From: Offroaders123 <65947371+Offroaders123@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:21:01 -0700 Subject: [PATCH 3/6] tsconfig Just to start things off. Will have to make some changes, as this is just the default config I use. --- tsconfig.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tsconfig.json diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..164363e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "module": "NodeNext", + "target": "ESNext", + "isolatedModules": true, + "noEmit": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "allowUnreachableCode": false, + "noUnusedLocals": true, + "allowUnusedLabels": false, + "noUnusedParameters": true + } +} From 9cb0e4f0b1a6d330aa18bf7e17e963773e3a6f50 Mon Sep 17 00:00:00 2001 From: Offroaders123 <65947371+Offroaders123@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:23:47 -0700 Subject: [PATCH 4/6] Type Dependencies Marking these as specific dependencies for the dev environment. --- package-lock.json | 24 +++++++++++++++++++++--- package.json | 4 ++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f44e714..f844ea9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,10 @@ "dependencies": { "minecraft-protocol": "^1.64.0", "prismarine-auth": "^2.7.0" + }, + "devDependencies": { + "@types/node": "^25.4.0", + "typescript": "^5.9.3" } }, "node_modules/@azure/msal-common": { @@ -37,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "25.3.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.3.3.tgz", - "integrity": "sha512-DpzbrH7wIcBaJibpKo9nnSQL0MTRdnWttGyE5haGwK86xgMOkFLp7vEyfQPGLOJh5wNYiJ3V9PmUMDhV9u8kkQ==", + "version": "25.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.4.0.tgz", + "integrity": "sha512-9wLpoeWuBlcbBpOY3XmzSTG3oscB6xjBEEtn+pYXTfhyXhIxC5FsBer2KTopBlvKEiW9l13po9fq+SJY/5lkhw==", "license": "MIT", "dependencies": { "undici-types": "~7.18.0" @@ -760,6 +764,20 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "license": "MIT" }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici-types": { "version": "7.18.2", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", diff --git a/package.json b/package.json index a6fc8f7..958d1fd 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,9 @@ "dependencies": { "minecraft-protocol": "^1.64.0", "prismarine-auth": "^2.7.0" + }, + "devDependencies": { + "@types/node": "^25.4.0", + "typescript": "^5.9.3" } } From e69289c9a6fa397becff8a007b0bdc18f10f3cba Mon Sep 17 00:00:00 2001 From: Offroaders123 <65947371+Offroaders123@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:50:57 -0700 Subject: [PATCH 5/6] Initial Types --- src/auth.js | 1 + src/mappings/blockmapping.js | 3 ++ src/mappings/entitymapping.js | 3 ++ src/mappings/itemmapping.js | 3 ++ src/mappings/recipemapping.js | 1 + src/mappings/soundmapping.js | 5 +++ src/packetreader.js | 39 +++++++++++++++++++++++ src/packetwriter.js | 60 +++++++++++++++++++++++++++++++++++ src/utils.js | 4 +++ src/utils/chunk.js | 12 ++++++- src/utils/items.js | 18 +++++++++++ src/utils/rotation.js | 4 +++ src/utils/translations.js | 5 +++ 13 files changed, 157 insertions(+), 1 deletion(-) diff --git a/src/auth.js b/src/auth.js index e625043..f8409f8 100644 --- a/src/auth.js +++ b/src/auth.js @@ -6,6 +6,7 @@ const AUTH_CACHE_DIR = path.join(__dirname, "..", ".auth_cache"); class MicrosoftAuth { constructor() { + /** @type {Authflow | null} */ this.authflow = null; this.authenticated = false; this.username = null; diff --git a/src/mappings/blockmapping.js b/src/mappings/blockmapping.js index 467f0a2..4f3b5b0 100644 --- a/src/mappings/blockmapping.js +++ b/src/mappings/blockmapping.js @@ -1,6 +1,9 @@ /* --------------------------------------------------------------- */ /* blockmapping.js */ /* --------------------------------------------------------------- */ +/** + * @returns {Record} + */ function createBlockMapping() { return { 0: 0, diff --git a/src/mappings/entitymapping.js b/src/mappings/entitymapping.js index 45aacfb..0099df5 100644 --- a/src/mappings/entitymapping.js +++ b/src/mappings/entitymapping.js @@ -1,6 +1,9 @@ /* --------------------------------------------------------------- */ /* entitymapping.js */ /* --------------------------------------------------------------- */ +/** + * @returns {Record} + */ function createEntityTypeMapping() { return { //monsters diff --git a/src/mappings/itemmapping.js b/src/mappings/itemmapping.js index 1ba7e8f..323f5e9 100644 --- a/src/mappings/itemmapping.js +++ b/src/mappings/itemmapping.js @@ -1,6 +1,9 @@ /* --------------------------------------------------------------- */ /* itemmapping.js */ /* --------------------------------------------------------------- */ +/** + * @returns {Record} + */ function createItemMapping() { return { 256: 256, //iron_shovel diff --git a/src/mappings/recipemapping.js b/src/mappings/recipemapping.js index ffa4990..124354b 100644 --- a/src/mappings/recipemapping.js +++ b/src/mappings/recipemapping.js @@ -3,6 +3,7 @@ //unfinised as of 3/9/2026 (MM/DD/YY) +/** @type {Record} */ module.exports = { //page 1 0: [ diff --git a/src/mappings/soundmapping.js b/src/mappings/soundmapping.js index 8d3fb07..8c2b48c 100644 --- a/src/mappings/soundmapping.js +++ b/src/mappings/soundmapping.js @@ -1,7 +1,12 @@ /* --------------------------------------------------------------- */ /* soundmapping.js */ /* --------------------------------------------------------------- */ +/** + * @param {string} soundName + * @returns {number} + */ function mapJavaSoundToLCE(soundName) { + /** @type {Record} */ const soundMap = { "mob.chicken.say": 0, "mob.chicken": 0, diff --git a/src/packetreader.js b/src/packetreader.js index e75da1c..5498a53 100644 --- a/src/packetreader.js +++ b/src/packetreader.js @@ -2,51 +2,79 @@ /* packetreader.js */ /* --------------------------------------------------------------- */ class PacketReader { + /** + * @param {Buffer} buffer + */ constructor(buffer) { this.buffer = buffer; this.offset = 0; } + /** + * @returns {number} + */ readByte() { const value = this.buffer.readInt8(this.offset); this.offset += 1; return value; } + /** + * @returns {number} + */ readUnsignedByte() { const value = this.buffer.readUInt8(this.offset); this.offset += 1; return value; } + /** + * @returns {number} + */ readShort() { const value = this.buffer.readInt16BE(this.offset); this.offset += 2; return value; } + /** + * @returns {number} + */ readInt() { const value = this.buffer.readInt32BE(this.offset); this.offset += 4; return value; } + /** + * @returns {bigint} + */ readLong() { const value = this.buffer.readBigInt64BE(this.offset); this.offset += 8; return value; } + /** + * @returns {number} + */ + // @ts-expect-error - Duplicate definition, identical readFloat() { const value = this.buffer.readFloatBE(this.offset); this.offset += 4; return value; } + /** + * @returns {boolean} + */ readBoolean() { return this.readByte() !== 0; } + /** + * @returns {string} + */ readString() { const length = this.readShort(); let str = ""; @@ -58,18 +86,29 @@ class PacketReader { return str; } + /** + * @returns {number} + */ readDouble() { const value = this.buffer.readDoubleBE(this.offset); this.offset += 8; return value; } + /** + * @returns {number} + */ + // @ts-expect-error - Duplicate definition, identical readFloat() { const value = this.buffer.readFloatBE(this.offset); this.offset += 4; return value; } + /** + * @param {number} bytes + * @returns {void} + */ skip(bytes) { this.offset += bytes; } diff --git a/src/packetwriter.js b/src/packetwriter.js index 82a3a2d..4c9db51 100644 --- a/src/packetwriter.js +++ b/src/packetwriter.js @@ -3,67 +3,116 @@ /* --------------------------------------------------------------- */ class PacketWriter { constructor() { + /** + * @type {Buffer[]} + */ this.buffers = []; } + /** + * @param {number} value + * @returns {void} + */ writeByte(value) { const buf = Buffer.allocUnsafe(1); buf.writeUInt8(value, 0); this.buffers.push(buf); } + /** + * @param {number} value + * @returns {void} + */ + // @ts-expect-error - Duplicate definition, identical writeSignedByte(value) { const buf = Buffer.allocUnsafe(1); buf.writeInt8(value, 0); this.buffers.push(buf); } + /** + * @param {number} value + * @returns {void} + */ + // @ts-expect-error - Duplicate definition, identical writeSignedByte(value) { const buf = Buffer.allocUnsafe(1); buf.writeInt8(value, 0); this.buffers.push(buf); } + /** + * @param {number} value + * @returns {void} + */ writeShort(value) { const buf = Buffer.allocUnsafe(2); buf.writeInt16BE(value, 0); this.buffers.push(buf); } + /** + * @param {number} value + * @returns {void} + */ writeInt(value) { const buf = Buffer.allocUnsafe(4); buf.writeInt32BE(value, 0); this.buffers.push(buf); } + /** + * @param {number} value + * @returns {void} + */ writeLong(value) { const buf = Buffer.allocUnsafe(8); buf.writeBigInt64BE(BigInt(value), 0); this.buffers.push(buf); } + /** + * @param {number} value + * @returns {void} + */ writeDouble(value) { const buf = Buffer.allocUnsafe(8); buf.writeDoubleBE(value, 0); this.buffers.push(buf); } + /** + * @param {number} value + * @returns {void} + */ writeFloat(value) { const buf = Buffer.allocUnsafe(4); buf.writeFloatBE(value, 0); this.buffers.push(buf); } + /** + * @param {boolean} value + * @returns {void} + */ writeBoolean(value) { this.writeByte(value ? 1 : 0); } + /** + * @param {string} str + * @returns {void} + */ writeUTF(str) { const utf8Buffer = Buffer.from(str, "utf8"); this.writeShort(utf8Buffer.length); this.buffers.push(utf8Buffer); } + /** + * @param {string} str + * @returns {void} + */ writeString(str) { this.writeShort(str.length); for (let i = 0; i < str.length; i++) { @@ -73,6 +122,10 @@ class PacketWriter { } } + /** + * @param {string} str + * @returns {void} + */ writeUtf(str) { this.writeShort(str.length); for (let i = 0; i < str.length; i++) { @@ -80,10 +133,17 @@ class PacketWriter { } } + /** + * @param {Buffer} buffer + * @returns {void} + */ writeBytes(buffer) { this.buffers.push(buffer); } + /** + * @returns {Buffer} + */ toBuffer() { return Buffer.concat(this.buffers); } diff --git a/src/utils.js b/src/utils.js index b14b6eb..089da7c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,6 +1,10 @@ /* --------------------------------------------------------------- */ /* utils.js */ /* --------------------------------------------------------------- */ +/** + * @param {number} value + * @returns {Buffer} + */ function encodeVarInt(value) { const bytes = []; do { diff --git a/src/utils/chunk.js b/src/utils/chunk.js index 2a8698f..c565e04 100644 --- a/src/utils/chunk.js +++ b/src/utils/chunk.js @@ -1,12 +1,18 @@ /* --------------------------------------------------------------- */ /* chunk.js */ /* --------------------------------------------------------------- */ +/** + * @param {Buffer} data + * @returns {Buffer} + */ function compressRLE(data) { + /** @type {number[]} */ const output = []; let i = 0; while (i < data.length) { - const byte = data[i]; + /** @type {number} */ + const byte = /** @type {number} */ (data[i]); let count = 1; while (i + count < data.length && data[i + count] === byte && count < 256) { @@ -31,6 +37,10 @@ function compressRLE(data) { return Buffer.from(output); } +/** + * @param {number} n + * @returns {number} + */ function countSetBits(n) { let count = 0; while (n) { diff --git a/src/utils/items.js b/src/utils/items.js index 9cfc4f3..2ba8b60 100644 --- a/src/utils/items.js +++ b/src/utils/items.js @@ -1,6 +1,9 @@ /* --------------------------------------------------------------- */ /* items.js */ /* --------------------------------------------------------------- */ +/** + * @param {import("../packetreader.js")} reader + */ function readSlot(reader) { const id = reader.readShort(); if (id === -1 || id === 0) { @@ -21,6 +24,9 @@ function readSlot(reader) { }; } +/** + * @param {import("../packetreader.js")} reader + */ function readItemInstance(reader) { const id = reader.readShort(); if (id === -1 || id === 0) { @@ -41,6 +47,9 @@ function readItemInstance(reader) { }; } +/** + * @param {import("../packetreader.js")} reader + */ function readItem(reader) { const itemId = reader.readShort(); @@ -66,6 +75,10 @@ function readItem(reader) { }; } +/** + * @param {import("../packetwriter.js")} writer + * @param item + */ function writeItemNBT(writer, item) { const PacketWriter = require("../packetwriter"); @@ -138,6 +151,11 @@ function writeItemNBT(writer, item) { writer.writeBytes(nbtData); } +/** + * @param {import("../packetwriter.js")} writer + * @param item + * @param mapJavaItemToLCE + */ function writeItem(writer, item, mapJavaItemToLCE) { if (!item || item.blockId === -1 || item.itemId === -1 || item === null) { writer.writeShort(-1); diff --git a/src/utils/rotation.js b/src/utils/rotation.js index d2fd798..3401a05 100644 --- a/src/utils/rotation.js +++ b/src/utils/rotation.js @@ -1,6 +1,10 @@ /* --------------------------------------------------------------- */ /* rotation.js */ /* --------------------------------------------------------------- */ +/** + * @param {number} yaw + * @returns {number} + */ function normalizeYaw(yaw) { let normalized = yaw % 360; if (normalized > 180) { diff --git a/src/utils/translations.js b/src/utils/translations.js index a3cc5d6..ec15d27 100644 --- a/src/utils/translations.js +++ b/src/utils/translations.js @@ -1,7 +1,12 @@ /* --------------------------------------------------------------- */ /* translations.js */ /* --------------------------------------------------------------- */ +/** + * @param {string} key + * @param {unknown[]} args + */ function getTranslation(key, args = []) { + /** @type {Record string>} */ const translations = {}; const translationFunc = translations[key]; From 0d847fbf8749185eb2f362c157dfb22c59246a6a Mon Sep 17 00:00:00 2001 From: Offroaders123 <65947371+Offroaders123@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:54:41 -0700 Subject: [PATCH 6/6] CommonJS Module Flag Forgot to update this flag, as it's not ESM, quite yet at least. Will look into that once everything is type-checked. --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 164363e..0ba6186 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "allowJs": true, "checkJs": true, - "module": "NodeNext", + "module": "CommonJS", "target": "ESNext", "isolatedModules": true, "noEmit": true,