Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +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)
Expand Down
24 changes: 21 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 1 addition & 0 deletions src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/mappings/blockmapping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* --------------------------------------------------------------- */
/* blockmapping.js */
/* --------------------------------------------------------------- */
/**
* @returns {Record<number, number>}
*/
function createBlockMapping() {
return {
0: 0,
Expand Down
3 changes: 3 additions & 0 deletions src/mappings/entitymapping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* --------------------------------------------------------------- */
/* entitymapping.js */
/* --------------------------------------------------------------- */
/**
* @returns {Record<string, number>}
*/
function createEntityTypeMapping() {
return {
//monsters
Expand Down
3 changes: 3 additions & 0 deletions src/mappings/itemmapping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* --------------------------------------------------------------- */
/* itemmapping.js */
/* --------------------------------------------------------------- */
/**
* @returns {Record<number, number>}
*/
function createItemMapping() {
return {
256: 256, //iron_shovel
Expand Down
1 change: 1 addition & 0 deletions src/mappings/recipemapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

//unfinised as of 3/9/2026 (MM/DD/YY)

/** @type {Record<number, string[]>} */
module.exports = {
//page 1
0: [
Expand Down
5 changes: 5 additions & 0 deletions src/mappings/soundmapping.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/* --------------------------------------------------------------- */
/* soundmapping.js */
/* --------------------------------------------------------------- */
/**
* @param {string} soundName
* @returns {number}
*/
function mapJavaSoundToLCE(soundName) {
/** @type {Record<string, number>} */
const soundMap = {
"mob.chicken.say": 0,
"mob.chicken": 0,
Expand Down
39 changes: 39 additions & 0 deletions src/packetreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,79 @@
/* packetreader.js */
/* --------------------------------------------------------------- */
class PacketReader {
/**
* @param {Buffer<ArrayBuffer>} 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 = "";
Expand All @@ -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;
}
Expand Down
60 changes: 60 additions & 0 deletions src/packetwriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,116 @@
/* --------------------------------------------------------------- */
class PacketWriter {
constructor() {
/**
* @type {Buffer<ArrayBuffer>[]}
*/
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++) {
Expand All @@ -73,17 +122,28 @@ class PacketWriter {
}
}

/**
* @param {string} str
* @returns {void}
*/
writeUtf(str) {
this.writeShort(str.length);
for (let i = 0; i < str.length; i++) {
this.writeShort(str.charCodeAt(i));
}
}

/**
* @param {Buffer<ArrayBuffer>} buffer
* @returns {void}
*/
writeBytes(buffer) {
this.buffers.push(buffer);
}

/**
* @returns {Buffer<ArrayBuffer>}
*/
toBuffer() {
return Buffer.concat(this.buffers);
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* --------------------------------------------------------------- */
/* utils.js */
/* --------------------------------------------------------------- */
/**
* @param {number} value
* @returns {Buffer<ArrayBuffer>}
*/
function encodeVarInt(value) {
const bytes = [];
do {
Expand Down
Loading