Compare commits
3 commits
next
...
up-protoco
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e1aaceb07 | ||
|
|
9a8c840d35 | ||
|
|
0b9b6cb661 |
4 changed files with 36 additions and 67 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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,8 +11,8 @@ 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] = {
|
||||||
- publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
|
- publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
|
||||||
|
|
@ -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,16 +29,16 @@ 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) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- client._signedChat = (message, options = {}) => {
|
- client._signedChat = (message, options = {}) => {
|
||||||
+ client._signedChat = async (message, options = {}) => {
|
+ client._signedChat = async (message, options = {}) => {
|
||||||
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,
|
||||||
|
|
@ -71,10 +71,10 @@ index 63cc2bd9615100bd2fd63dfe14c094aa6b8cd1c9..36df57d1196af9761d920fa285ac48f8
|
||||||
+ // clearTimeout(loginTimeout)
|
+ // clearTimeout(loginTimeout)
|
||||||
+ // })
|
+ // })
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
|
@ -94,7 +94,7 @@ index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c
|
||||||
}
|
}
|
||||||
@@ -169,7 +175,10 @@ class Client extends EventEmitter {
|
@@ -169,7 +175,10 @@ class Client extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const onFatalError = (err) => {
|
const onFatalError = (err) => {
|
||||||
- this.emit('error', err)
|
- this.emit('error', err)
|
||||||
+ // todo find out what is trying to write after client disconnect
|
+ // todo find out what is trying to write after client disconnect
|
||||||
|
|
@ -103,58 +103,23 @@ 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)
|
||||||
}
|
}
|
||||||
+ this.emit('writePacket', name, params)
|
+ this.emit('writePacket', name, params)
|
||||||
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
16
pnpm-lock.yaml
generated
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue