Skip to content

Commit 4d977d3

Browse files
authored
good release (#216)
2 parents f1f4078 + 7086756 commit 4d977d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1654
-800
lines changed

CONTRIBUTING.md

+10
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ New React components, improve UI (including mobile support).
169169
3. Develop, try to fix and test. Finally we should find a way to fix it. It's ideal to have an automatic test but it's not necessary for now
170170
3. Repeat step 1 to make sure the task is done and the problem is fixed (or the feature is implemented)
171171

172+
## Updating Dependencies
173+
174+
1. Ensure mineflayer fork is up to date with the latest version of mineflayer original repo
175+
2. Update PrismarineJS dependencies to the latest version: `minecraft-data` (be sure to replace the version twice in the package.json), `mineflayer`, `minecraft-protocol`, `prismarine-block`, `prismarine-chunk`, `prismarine-item`, ...
176+
3. If `minecraft-protocol` patch fails, do this:
177+
1. Remove the patch from `patchedDependencies` in `package.json`
178+
2. Run `pnpm patch minecraft-protocol`, open patch directory
179+
3. Apply the patch manually in this directory: `patch -p1 < minecraft-protocol@<version>.patch`
180+
4. Run the suggested command from `pnpm patch ...` (previous step) to update the patch
181+
172182
### Would be useful to have
173183

174184
- cleanup folder & modules structure, cleanup playground code

package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@
6767
"esbuild-plugin-polyfill-node": "^0.3.0",
6868
"express": "^4.18.2",
6969
"filesize": "^10.0.12",
70-
"flying-squid": "npm:@zardoy/flying-squid@^0.0.41",
70+
"flying-squid": "npm:@zardoy/flying-squid@^0.0.44",
7171
"fs-extra": "^11.1.1",
7272
"google-drive-browserfs": "github:zardoy/browserfs#google-drive",
7373
"jszip": "^3.10.1",
7474
"lodash-es": "^4.17.21",
75-
"minecraft-data": "3.65.0",
75+
"minecraft-data": "3.76.0",
7676
"minecraft-protocol": "github:PrismarineJS/node-minecraft-protocol#master",
7777
"mineflayer-item-map-downloader": "github:zardoy/mineflayer-item-map-downloader",
7878
"mojangson": "^2.0.4",
@@ -172,20 +172,21 @@
172172
"diamond-square": "github:zardoy/diamond-square",
173173
"prismarine-block": "github:zardoy/prismarine-block#next-era",
174174
"prismarine-world": "github:zardoy/prismarine-world#next-era",
175-
"minecraft-data": "3.65.0",
175+
"minecraft-data": "3.76.0",
176176
"prismarine-provider-anvil": "github:zardoy/prismarine-provider-anvil#everything",
177177
"minecraft-protocol": "github:PrismarineJS/node-minecraft-protocol#master",
178178
"react": "^18.2.0",
179-
"prismarine-chunk": "github:zardoy/prismarine-chunk"
179+
"prismarine-chunk": "github:zardoy/prismarine-chunk",
180+
"prismarine-item": "latest"
180181
},
181182
"updateConfig": {
182183
"ignoreDependencies": []
183184
},
184185
"patchedDependencies": {
185-
186186
187187
188-
188+
189+
189190
}
190191
},
191192
"packageManager": "[email protected]"

patches/[email protected] patches/[email protected]

+73-73
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,71 @@ index c437ecf3a0e4ab5758a48538c714b7e9651bb5da..d9c9895ae8614550aa09ad60a396ac32
1212
debug('ping response', response)
1313
// TODO: could also use ping pre-connect to save description, type, max players, etc.
1414
@@ -40,6 +40,7 @@ module.exports = function (client, options) {
15-
15+
1616
// Reinitialize client object with new version TODO: move out of its constructor?
1717
client.version = minecraftVersion
1818
+ await options.versionSelectedHook?.(client)
1919
client.state = states.HANDSHAKING
20-
20+
2121
// Let other plugins such as Forge/FML (modinfo) respond to the ping response
22+
diff --git a/src/client/chat.js b/src/client/chat.js
23+
index f14269bea055d4329cd729271e7406ec4b344de7..00f5482eb6e3c911381ca9a728b1b4aae0d1d337 100644
24+
--- a/src/client/chat.js
25+
+++ b/src/client/chat.js
26+
@@ -111,7 +111,7 @@ module.exports = function (client, options) {
27+
for (const player of packet.data) {
28+
if (!player.chatSession) continue
29+
client._players[player.UUID] = {
30+
- publicKey: crypto.createPublicKey({ key: player.chatSession.publicKey.keyBytes, format: 'der', type: 'spki' }),
31+
+ // publicKey: crypto.createPublicKey({ key: player.chatSession.publicKey.keyBytes, format: 'der', type: 'spki' }),
32+
publicKeyDER: player.chatSession.publicKey.keyBytes,
33+
sessionUuid: player.chatSession.uuid
34+
}
35+
@@ -127,7 +127,7 @@ module.exports = function (client, options) {
36+
for (const player of packet.data) {
37+
if (player.crypto) {
38+
client._players[player.UUID] = {
39+
- publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
40+
+ // publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
41+
publicKeyDER: player.crypto.publicKey,
42+
signature: player.crypto.signature,
43+
displayName: player.displayName || player.name
44+
@@ -198,7 +198,7 @@ module.exports = function (client, options) {
45+
if (mcData.supportFeature('useChatSessions')) {
46+
const tsDelta = BigInt(Date.now()) - packet.timestamp
47+
const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0
48+
- const verified = !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired
49+
+ const verified = false && !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired
50+
if (verified) client._signatureCache.push(packet.signature)
51+
client.emit('playerChat', {
52+
plainMessage: packet.plainMessage,
53+
@@ -363,7 +363,7 @@ module.exports = function (client, options) {
54+
}
55+
}
56+
57+
- client._signedChat = (message, options = {}) => {
58+
+ client._signedChat = async (message, options = {}) => {
59+
options.timestamp = options.timestamp || BigInt(Date.now())
60+
options.salt = options.salt || 1n
61+
62+
@@ -405,7 +405,7 @@ module.exports = function (client, options) {
63+
message,
64+
timestamp: options.timestamp,
65+
salt: options.salt,
66+
- signature: (client.profileKeys && client._session) ? client.signMessage(message, options.timestamp, options.salt, undefined, acknowledgements) : undefined,
67+
+ signature: (client.profileKeys && client._session) ? await client.signMessage(message, options.timestamp, options.salt, undefined, acknowledgements) : undefined,
68+
offset: client._lastSeenMessages.pending,
69+
acknowledged
70+
})
71+
@@ -419,7 +419,7 @@ module.exports = function (client, options) {
72+
message,
73+
timestamp: options.timestamp,
74+
salt: options.salt,
75+
- signature: client.profileKeys ? client.signMessage(message, options.timestamp, options.salt, options.preview) : Buffer.alloc(0),
76+
+ signature: client.profileKeys ? await client.signMessage(message, options.timestamp, options.salt, options.preview) : Buffer.alloc(0),
77+
signedPreview: options.didPreview,
78+
previousMessages: client._lastSeenMessages.map((e) => ({
79+
messageSender: e.sender,
2280
diff --git a/src/client/encrypt.js b/src/client/encrypt.js
2381
index b9d21bab9faccd5dbf1975fc423fc55c73e906c5..99ffd76527b410e3a393181beb260108f4c63536 100644
2482
--- a/src/client/encrypt.js
@@ -34,10 +92,10 @@ index b9d21bab9faccd5dbf1975fc423fc55c73e906c5..99ffd76527b410e3a393181beb260108
3492
+ // clearTimeout(loginTimeout)
3593
+ // })
3694
}
37-
95+
3896
function onJoinServerResponse (err) {
3997
diff --git a/src/client.js b/src/client.js
40-
index c89375e32babbf3559655b1e95f6441b9a30796f..f24cd5dc8fa9a0a4000b184fb3c79590a3ad8b8a 100644
98+
index 5b63c295080f62ca54928660cdfa134214002fa1..d2d24bff963d8ed7747ccb48f8c278950ba7f396 100644
4199
--- a/src/client.js
42100
+++ b/src/client.js
43101
@@ -88,10 +88,12 @@ class Client extends EventEmitter {
@@ -72,9 +130,9 @@ index c89375e32babbf3559655b1e95f6441b9a30796f..f24cd5dc8fa9a0a4000b184fb3c79590
72130
}
73131
})
74132
}
75-
@@ -166,7 +174,10 @@ class Client extends EventEmitter {
133+
@@ -167,7 +175,10 @@ class Client extends EventEmitter {
76134
}
77-
135+
78136
const onFatalError = (err) => {
79137
- this.emit('error', err)
80138
+ // todo find out what is trying to write after client disconnect
@@ -83,8 +141,8 @@ index c89375e32babbf3559655b1e95f6441b9a30796f..f24cd5dc8fa9a0a4000b184fb3c79590
83141
+ }
84142
endSocket()
85143
}
86-
87-
@@ -195,6 +206,8 @@ class Client extends EventEmitter {
144+
145+
@@ -196,6 +207,8 @@ class Client extends EventEmitter {
88146
serializer -> framer -> socket -> splitter -> deserializer */
89147
if (this.serializer) {
90148
this.serializer.end()
@@ -93,8 +151,8 @@ index c89375e32babbf3559655b1e95f6441b9a30796f..f24cd5dc8fa9a0a4000b184fb3c79590
93151
} else {
94152
if (this.socket) this.socket.end()
95153
}
96-
@@ -236,8 +249,11 @@ class Client extends EventEmitter {
97-
154+
@@ -237,8 +250,11 @@ class Client extends EventEmitter {
155+
98156
write (name, params) {
99157
if (!this.serializer.writable) { return }
100158
- debug('writing packet ' + this.state + '.' + name)
@@ -106,83 +164,25 @@ index c89375e32babbf3559655b1e95f6441b9a30796f..f24cd5dc8fa9a0a4000b184fb3c79590
106164
+ this.emit('writePacket', name, params)
107165
this.serializer.write({ name, params })
108166
}
109-
167+
110168
diff --git a/src/index.d.ts b/src/index.d.ts
111-
index 0a5821c32d735e11205a280aa5a503c13533dc14..94a49f661d922478b940d853169b6087e6ec3df5 100644
169+
index 423085259176a10c9dfeb617f00975df077d02be..ae0558b7c53ab24474b22240e8a2f4e4cde02f19 100644
112170
--- a/src/index.d.ts
113171
+++ b/src/index.d.ts
114-
@@ -121,6 +121,7 @@ declare module 'minecraft-protocol' {
172+
@@ -134,6 +134,7 @@ declare module 'minecraft-protocol' {
115173
sessionServer?: string
116174
keepAlive?: boolean
117175
closeTimeout?: number
118176
+ closeTimeout?: number
119177
noPongTimeout?: number
120178
checkTimeoutInterval?: number
121179
version?: string
122-
@@ -141,6 +142,8 @@ declare module 'minecraft-protocol' {
180+
@@ -154,6 +155,8 @@ declare module 'minecraft-protocol' {
123181
disableChatSigning?: boolean
124182
/** Pass custom client implementation if needed. */
125183
Client?: Client
126184
+ /** Can be used to prepare mc data on autoVersion (client.version has selected version) */
127185
+ versionSelectedHook?: (client: Client) => Promise<void> | void
128186
}
129-
187+
130188
export class Server extends EventEmitter {
131-
diff --git a/src/client/chat.js b/src/client/chat.js
132-
index 5cad9954db13d7121ed0a03792c2304156cdf436..ffd7c7d6299ef54854e0923f8d5296bf2a58956b 100644
133-
--- a/src/client/chat.js
134-
+++ b/src/client/chat.js
135-
@@ -111,7 +111,7 @@ module.exports = function (client, options) {
136-
for (const player of packet.data) {
137-
if (!player.chatSession) continue
138-
client._players[player.UUID] = {
139-
- publicKey: crypto.createPublicKey({ key: player.chatSession.publicKey.keyBytes, format: 'der', type: 'spki' }),
140-
+ // publicKey: crypto.createPublicKey({ key: player.chatSession.publicKey.keyBytes, format: 'der', type: 'spki' }),
141-
publicKeyDER: player.chatSession.publicKey.keyBytes,
142-
sessionUuid: player.chatSession.uuid
143-
}
144-
@@ -127,7 +127,7 @@ module.exports = function (client, options) {
145-
for (const player of packet.data) {
146-
if (player.crypto) {
147-
client._players[player.UUID] = {
148-
- publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
149-
+ // publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
150-
publicKeyDER: player.crypto.publicKey,
151-
signature: player.crypto.signature,
152-
displayName: player.displayName || player.name
153-
@@ -198,7 +198,7 @@ module.exports = function (client, options) {
154-
if (mcData.supportFeature('useChatSessions')) {
155-
const tsDelta = BigInt(Date.now()) - packet.timestamp
156-
const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0
157-
- const verified = !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired
158-
+ const verified = false && !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired
159-
if (verified) client._signatureCache.push(packet.signature)
160-
client.emit('playerChat', {
161-
plainMessage: packet.plainMessage,
162-
@@ -363,7 +363,7 @@ module.exports = function (client, options) {
163-
}
164-
}
165-
166-
- client._signedChat = (message, options = {}) => {
167-
+ client._signedChat = async (message, options = {}) => {
168-
options.timestamp = options.timestamp || BigInt(Date.now())
169-
options.salt = options.salt || 1n
170-
171-
@@ -404,7 +404,7 @@ module.exports = function (client, options) {
172-
message,
173-
timestamp: options.timestamp,
174-
salt: options.salt,
175-
- signature: (client.profileKeys && client._session) ? client.signMessage(message, options.timestamp, options.salt, undefined, acknowledgements) : undefined,
176-
+ signature: (client.profileKeys && client._session) ? await client.signMessage(message, options.timestamp, options.salt, undefined, acknowledgements) : undefined,
177-
offset: client._lastSeenMessages.pending,
178-
acknowledged
179-
})
180-
@@ -418,7 +418,7 @@ module.exports = function (client, options) {
181-
message,
182-
timestamp: options.timestamp,
183-
salt: options.salt,
184-
- signature: client.profileKeys ? client.signMessage(message, options.timestamp, options.salt, options.preview) : Buffer.alloc(0),
185-
+ signature: client.profileKeys ? await client.signMessage(message, options.timestamp, options.salt, options.preview) : Buffer.alloc(0),
186-
signedPreview: options.didPreview,
187-
previousMessages: client._lastSeenMessages.map((e) => ({
188-
messageSender: e.sender,

0 commit comments

Comments
 (0)