Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
Vitaly Turovsky
9e1aaceb07 fix patches path 2025-08-08 02:06:57 +03:00
Vitaly Turovsky
9a8c840d35 up proto 2025-08-08 02:03:37 +03:00
Vitaly
0b9b6cb661 part 1 2025-08-08 01:56:04 +03:00
4 changed files with 36 additions and 67 deletions

View file

@ -54,7 +54,7 @@ Howerver, it's known that these browsers have issues:
### Versions Support ### Versions Support
Server versions 1.8 - 1.21.4 are supported. Server versions 1.8 - 1.21.5 are supported.
First class versions (most of the features are tested on these versions): First class versions (most of the features are tested on these versions):
- 1.19.4 - 1.19.4

View file

@ -1,8 +1,8 @@
diff --git a/src/client/chat.js b/src/client/chat.js diff --git a/src/client/chat.js b/src/client/chat.js
index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648303628c7 100644 index 0021870994fc59a82f0ac8aba0a65a8be43ef2f4..a53fceb843105ea2a1d88722b3fc7c3b43cb102a 100644
--- a/src/client/chat.js --- a/src/client/chat.js
+++ b/src/client/chat.js +++ b/src/client/chat.js
@@ -110,7 +110,7 @@ module.exports = function (client, options) { @@ -116,7 +116,7 @@ module.exports = function (client, options) {
for (const player of packet.data) { for (const player of packet.data) {
if (player.chatSession) { if (player.chatSession) {
client._players[player.uuid] = { client._players[player.uuid] = {
@ -11,7 +11,7 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
publicKeyDER: player.chatSession.publicKey.keyBytes, publicKeyDER: player.chatSession.publicKey.keyBytes,
sessionUuid: player.chatSession.uuid sessionUuid: player.chatSession.uuid
} }
@@ -120,7 +120,7 @@ module.exports = function (client, options) { @@ -126,7 +126,7 @@ module.exports = function (client, options) {
if (player.crypto) { if (player.crypto) {
client._players[player.uuid] = { client._players[player.uuid] = {
@ -20,7 +20,7 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
publicKeyDER: player.crypto.publicKey, publicKeyDER: player.crypto.publicKey,
signature: player.crypto.signature, signature: player.crypto.signature,
displayName: player.displayName || player.name displayName: player.displayName || player.name
@@ -190,7 +190,7 @@ module.exports = function (client, options) { @@ -196,7 +196,7 @@ module.exports = function (client, options) {
if (mcData.supportFeature('useChatSessions')) { if (mcData.supportFeature('useChatSessions')) {
const tsDelta = BigInt(Date.now()) - packet.timestamp const tsDelta = BigInt(Date.now()) - packet.timestamp
const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0 const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0
@ -29,7 +29,7 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
if (verified) client._signatureCache.push(packet.signature) if (verified) client._signatureCache.push(packet.signature)
client.emit('playerChat', { client.emit('playerChat', {
globalIndex: packet.globalIndex, globalIndex: packet.globalIndex,
@@ -356,7 +356,7 @@ module.exports = function (client, options) { @@ -362,7 +362,7 @@ module.exports = function (client, options) {
} }
} }
@ -38,7 +38,7 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
options.timestamp = options.timestamp || BigInt(Date.now()) options.timestamp = options.timestamp || BigInt(Date.now())
options.salt = options.salt || 1n options.salt = options.salt || 1n
@@ -401,7 +401,7 @@ module.exports = function (client, options) { @@ -407,7 +407,7 @@ module.exports = function (client, options) {
message, message,
timestamp: options.timestamp, timestamp: options.timestamp,
salt: options.salt, salt: options.salt,
@ -47,7 +47,7 @@ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648
offset: client._lastSeenMessages.pending, offset: client._lastSeenMessages.pending,
checksum: computeChatChecksum(client._lastSeenMessages), // 1.21.5+ checksum: computeChatChecksum(client._lastSeenMessages), // 1.21.5+
acknowledged acknowledged
@@ -416,7 +416,7 @@ module.exports = function (client, options) { @@ -422,7 +422,7 @@ module.exports = function (client, options) {
message, message,
timestamp: options.timestamp, timestamp: options.timestamp,
salt: options.salt, salt: options.salt,
@ -74,7 +74,7 @@ index 63cc2bd9615100bd2fd63dfe14c094aa6b8cd1c9..36df57d1196af9761d920fa285ac48f8
function onJoinServerResponse (err) { function onJoinServerResponse (err) {
diff --git a/src/client.js b/src/client.js diff --git a/src/client.js b/src/client.js
index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c648ab192 100644 index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..54bb9e6644388e9b6bd42b3012951875989cdf0c 100644
--- a/src/client.js --- a/src/client.js
+++ b/src/client.js +++ b/src/client.js
@@ -111,7 +111,13 @@ class Client extends EventEmitter { @@ -111,7 +111,13 @@ class Client extends EventEmitter {
@ -104,16 +104,18 @@ index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c
endSocket() endSocket()
} }
@@ -198,6 +207,8 @@ class Client extends EventEmitter { @@ -198,6 +207,10 @@ class Client extends EventEmitter {
serializer -> framer -> socket -> splitter -> deserializer */ serializer -> framer -> socket -> splitter -> deserializer */
if (this.serializer) { if (this.serializer) {
this.serializer.end() this.serializer.end()
+ this.socket?.end() + setTimeout(() => {
+ this.socket?.emit('end') + this.socket?.end()
+ this.socket?.emit('end')
+ }, 2000) // allow the serializer to finish writing
} else { } else {
if (this.socket) this.socket.end() if (this.socket) this.socket.end()
} }
@@ -243,6 +254,7 @@ class Client extends EventEmitter { @@ -243,6 +256,7 @@ class Client extends EventEmitter {
debug('writing packet ' + this.state + '.' + name) debug('writing packet ' + this.state + '.' + name)
debug(params) debug(params)
} }
@ -121,40 +123,3 @@ index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c
this.serializer.write({ name, params }) this.serializer.write({ name, params })
} }
diff --git a/src/client.js.rej b/src/client.js.rej
new file mode 100644
index 0000000000000000000000000000000000000000..1101e2477adfdc004381b78e7d70953dacb7b484
--- /dev/null
+++ b/src/client.js.rej
@@ -0,0 +1,31 @@
+@@ -89,10 +89,12 @@
+ parsed.metadata.name = parsed.data.name
+ parsed.data = parsed.data.params
+ parsed.metadata.state = state
+- debug('read packet ' + state + '.' + parsed.metadata.name)
+- if (debug.enabled) {
+- const s = JSON.stringify(parsed.data, null, 2)
+- debug(s && s.length > 10000 ? parsed.data : s)
++ if (!globalThis.excludeCommunicationDebugEvents?.includes(parsed.metadata.name)) {
++ debug('read packet ' + state + '.' + parsed.metadata.name)
++ if (debug.enabled) {
++ const s = JSON.stringify(parsed.data, null, 2)
++ debug(s && s.length > 10000 ? parsed.data : s)
++ }
+ }
+ if (this._hasBundlePacket && parsed.metadata.name === 'bundle_delimiter') {
+ if (this._mcBundle.length) { // End bundle
+@@ -239,8 +252,11 @@
+
+ write (name, params) {
+ if (!this.serializer.writable) { return }
+- debug('writing packet ' + this.state + '.' + name)
+- debug(params)
++ if (!globalThis.excludeCommunicationDebugEvents?.includes(name)) {
++ debug(`[${this.state}] from ${this.isServer ? 'server' : 'client'}: ` + name)
++ debug(params)
++ }
++ this.emit('writePacket', name, params)
+ this.serializer.write({ name, params })
+ }
+

16
pnpm-lock.yaml generated
View file

@ -22,7 +22,7 @@ overrides:
patchedDependencies: patchedDependencies:
minecraft-protocol: minecraft-protocol:
hash: b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9 hash: 2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea
path: patches/minecraft-protocol.patch path: patches/minecraft-protocol.patch
mineflayer-item-map-downloader@1.2.0: mineflayer-item-map-downloader@1.2.0:
hash: a731ebbace2d8790c973ab3a5ba33494a6e9658533a9710dd8ba36f86db061ad hash: a731ebbace2d8790c973ab3a5ba33494a6e9658533a9710dd8ba36f86db061ad
@ -142,7 +142,7 @@ importers:
version: 3.92.0 version: 3.92.0
minecraft-protocol: minecraft-protocol:
specifier: github:PrismarineJS/node-minecraft-protocol#master specifier: github:PrismarineJS/node-minecraft-protocol#master
version: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9)(encoding@0.1.13) version: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea)(encoding@0.1.13)
mineflayer-item-map-downloader: mineflayer-item-map-downloader:
specifier: github:zardoy/mineflayer-item-map-downloader specifier: github:zardoy/mineflayer-item-map-downloader
version: https://codeload.github.com/zardoy/mineflayer-item-map-downloader/tar.gz/a8d210ecdcf78dd082fa149a96e1612cc9747824(patch_hash=a731ebbace2d8790c973ab3a5ba33494a6e9658533a9710dd8ba36f86db061ad)(encoding@0.1.13) version: https://codeload.github.com/zardoy/mineflayer-item-map-downloader/tar.gz/a8d210ecdcf78dd082fa149a96e1612cc9747824(patch_hash=a731ebbace2d8790c973ab3a5ba33494a6e9658533a9710dd8ba36f86db061ad)(encoding@0.1.13)
@ -13078,7 +13078,7 @@ snapshots:
flatmap: 0.0.3 flatmap: 0.0.3
long: 5.3.1 long: 5.3.1
minecraft-data: 3.92.0 minecraft-data: 3.92.0
minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9)(encoding@0.1.13) minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea)(encoding@0.1.13)
mkdirp: 2.1.6 mkdirp: 2.1.6
node-gzip: 1.1.2 node-gzip: 1.1.2
node-rsa: 1.1.1 node-rsa: 1.1.1
@ -13114,7 +13114,7 @@ snapshots:
flatmap: 0.0.3 flatmap: 0.0.3
long: 5.3.1 long: 5.3.1
minecraft-data: 3.92.0 minecraft-data: 3.92.0
minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9)(encoding@0.1.13) minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea)(encoding@0.1.13)
mkdirp: 2.1.6 mkdirp: 2.1.6
node-gzip: 1.1.2 node-gzip: 1.1.2
node-rsa: 1.1.1 node-rsa: 1.1.1
@ -16961,7 +16961,7 @@ snapshots:
dependencies: dependencies:
'@zardoy/flying-squid': 0.0.49(encoding@0.1.13) '@zardoy/flying-squid': 0.0.49(encoding@0.1.13)
exit-hook: 2.2.1 exit-hook: 2.2.1
minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9)(encoding@0.1.13) minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea)(encoding@0.1.13)
mineflayer: https://codeload.github.com/zardoy/mineflayer/tar.gz/c9c77d6511e37c452ebe48790724da165d6ad448(encoding@0.1.13) mineflayer: https://codeload.github.com/zardoy/mineflayer/tar.gz/c9c77d6511e37c452ebe48790724da165d6ad448(encoding@0.1.13)
prismarine-item: 1.17.0 prismarine-item: 1.17.0
ws: 8.18.1 ws: 8.18.1
@ -17280,7 +17280,7 @@ snapshots:
- '@types/react' - '@types/react'
- react - react
minecraft-protocol@https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9)(encoding@0.1.13): minecraft-protocol@https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea)(encoding@0.1.13):
dependencies: dependencies:
'@types/node-rsa': 1.1.4 '@types/node-rsa': 1.1.4
'@types/readable-stream': 4.0.18 '@types/readable-stream': 4.0.18
@ -17360,7 +17360,7 @@ snapshots:
mineflayer@4.31.0(encoding@0.1.13): mineflayer@4.31.0(encoding@0.1.13):
dependencies: dependencies:
minecraft-data: 3.92.0 minecraft-data: 3.92.0
minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9)(encoding@0.1.13) minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea)(encoding@0.1.13)
prismarine-biome: 1.3.0(minecraft-data@3.92.0)(prismarine-registry@1.11.0) prismarine-biome: 1.3.0(minecraft-data@3.92.0)(prismarine-registry@1.11.0)
prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/853c559bff2b402863ee9a75b125a3ca320838f9 prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/853c559bff2b402863ee9a75b125a3ca320838f9
prismarine-chat: 1.11.0 prismarine-chat: 1.11.0
@ -17384,7 +17384,7 @@ snapshots:
dependencies: dependencies:
'@nxg-org/mineflayer-physics-util': 1.8.10 '@nxg-org/mineflayer-physics-util': 1.8.10
minecraft-data: 3.92.0 minecraft-data: 3.92.0
minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=b417b3b7c5fd96e59abab5c1075b86b88bada2c980e4b54df13ca69b8f0091d9)(encoding@0.1.13) minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/b404bcaed4c039c5558e889c8617aa866cd7bddb(patch_hash=2a88e61fea1825d9fa5f1584fde810421d553d23e45e6dc829c3697ee3358bea)(encoding@0.1.13)
prismarine-biome: 1.3.0(minecraft-data@3.92.0)(prismarine-registry@1.11.0) prismarine-biome: 1.3.0(minecraft-data@3.92.0)(prismarine-registry@1.11.0)
prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/853c559bff2b402863ee9a75b125a3ca320838f9 prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/853c559bff2b402863ee9a75b125a3ca320838f9
prismarine-chat: 1.11.0 prismarine-chat: 1.11.0

View file

@ -231,8 +231,12 @@ export async function connect (connectOptions: ConnectOptions) {
bot.emit('end', '') bot.emit('end', '')
bot.removeAllListeners() bot.removeAllListeners()
bot._client.removeAllListeners() bot._client.removeAllListeners()
//@ts-expect-error TODO? bot._client = {
bot._client = undefined //@ts-expect-error
write (packetName) {
console.warn('Tried to write packet', packetName, 'after bot was destroyed')
}
}
//@ts-expect-error //@ts-expect-error
window.bot = bot = undefined window.bot = bot = undefined
} }