Skip to content

Commit

Permalink
Merge branch 'master' into master-msatoken
Browse files Browse the repository at this point in the history
  • Loading branch information
rom1504 authored Jan 6, 2025
2 parents c76b9bb + 8e131c3 commit cd84cae
Show file tree
Hide file tree
Showing 22 changed files with 534 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
- name: Install dependencies
run: npm install
Expand Down
17 changes: 17 additions & 0 deletions docs/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# History

## 1.51.0
* [Add type to serverKey in server (#1349)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/d6b4e82eb170984380e7ea9f125ea5d72777bef2) (thanks @u9g)
* [support 1.21.3 (#1347)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/2224d824065908e910520dfa8ea9f3f3ade242e4) (thanks @rom1504)
* [Bump @types/node from 20.16.15 to 22.7.9 (#1345)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/590dc33fed2100e77ef58e7db716dfc45eb61159) (thanks @dependabot[bot])

## 1.50.0
* [1.21 Support (#1342)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/5bebac36620d8f8ec256d19483e20e643d63de2a) (thanks @GroobleDierne)

## 1.49.0
* [support 1.20.6 (#1338)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/0b0012d60f0f1648be5ff705e7694bb1cd4ec37c) (thanks @rom1504)

## 1.48.0
* [1.20.5 (#1309)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/9b029e8b6f33d4e8ee1476de6821bad942f1ab6b) (thanks @extremeheat)
* [Fix realms loading issue due to createClient plugin init order (#1303)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/7057ad979b416192ada235f2f4e3b5eb26af5fa1) (thanks @extremeheat)
* [Update doc (#1300)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/495eed56ab230b2615596590064671356d86a2dc) (thanks @extremeheat)
* [Fix handling of disconnect in versionChecking on 1.20.3+. (#1291)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/ccab9fb39681f3ebe0d264e2a3f833aa3c5a1ac7) (thanks @wgaylord)

## 1.47.0
* [1.20.3 / 1.20.4 support (#1275)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/1d9a38253a28a515d82fffa13806cb0874c5b36c) (thanks @wgaylord)

Expand Down
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Parse and serialize minecraft packets, plus authentication and encryption.

* Supports Minecraft PC version 1.7.10, 1.8.8, 1.9 (15w40b, 1.9, 1.9.1-pre2, 1.9.2, 1.9.4),
1.10 (16w20a, 1.10-pre1, 1.10, 1.10.1, 1.10.2), 1.11 (16w35a, 1.11, 1.11.2), 1.12 (17w15a, 17w18b, 1.12-pre4, 1.12, 1.12.1, 1.12.2), and 1.13 (17w50a, 1.13, 1.13.1, 1.13.2-pre1, 1.13.2-pre2, 1.13.2), 1.14 (1.14, 1.14.1, 1.14.3, 1.14.4)
, 1.15 (1.15, 1.15.1, 1.15.2) and 1.16 (20w13b, 20w14a, 1.16-rc1, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5), 1.17 (21w07a, 1.17, 1.17.1), 1.18 (1.18, 1.18.1 and 1.18.2), 1.19 (1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4), 1.20 (1.20, 1.20.1, 1.20.2, 1.20.3 and 1.20.4)
, 1.15 (1.15, 1.15.1, 1.15.2) and 1.16 (20w13b, 20w14a, 1.16-rc1, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5), 1.17 (21w07a, 1.17, 1.17.1), 1.18 (1.18, 1.18.1 and 1.18.2), 1.19 (1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4), 1.20 (1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6), 1.21 (1.21, 1.21.1, 1.21.3)
* Parses all packets and emits events with packet fields as JavaScript
objects.
* Send a packet by supplying fields as a JavaScript object.
Expand Down Expand Up @@ -142,6 +142,7 @@ server.on('playerJoin', function(client) {

client.write('login', {
...loginPacket,
enforceSecureChat: false,
entityId: client.id,
hashedSeed: [0, 0],
maxPlayers: server.maxPlayers,
Expand Down
1 change: 1 addition & 0 deletions examples/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ server.on('playerJoin', function (client) {
// send init data so client will start rendering world
client.write('login', {
...loginPacket,
enforceSecureChat: false,
entityId: client.id,
isHardcore: false,
gameMode: 0,
Expand Down
1 change: 1 addition & 0 deletions examples/server_channel/server_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ server.on('playerJoin', function (client) {

client.write('login', {
...loginPacket,
enforceSecureChat: false,
entityId: client.id,
isHardcore: false,
gameMode: 0,
Expand Down
1 change: 1 addition & 0 deletions examples/server_custom_channel/server_custom_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const loginPacket = mcData.loginPacket
server.on('playerJoin', function (client) {
client.write('login', {
...loginPacket,
enforceSecureChat: false,
entityId: client.id,
isHardcore: false,
gameMode: 0,
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minecraft-protocol",
"version": "1.47.0",
"version": "1.51.0",
"description": "Parse and serialize minecraft packets, plus authentication and encryption.",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down Expand Up @@ -33,33 +33,35 @@
},
"browser": "src/browser.js",
"devDependencies": {
"@types/node": "^20.2.1",
"@types/node": "^22.7.9",
"espower-loader": "^1.0.0",
"intelli-espower-loader": "^1.0.0",
"minecraft-packets": "^1.1.5",
"minecraft-protocol": "file:.",
"minecraft-wrap": "^1.2.3",
"mocha": "^10.0.0",
"power-assert": "^1.0.0",
"standard": "^17.0.0"
"standard": "^17.0.0",
"prismarine-registry": "^1.8.0"
},
"dependencies": {
"@types/node-rsa": "^1.1.4",
"@types/readable-stream": "^4.0.0",
"aes-js": "^3.1.2",
"buffer-equal": "^1.0.0",
"debug": "^4.3.2",
"endian-toggle": "^0.0.0",
"lodash.get": "^4.1.2",
"lodash.merge": "^4.3.0",
"minecraft-data": "^3.55.0",
"minecraft-data": "^3.78.0",
"minecraft-folder-path": "^1.2.0",
"node-fetch": "^2.6.1",
"node-rsa": "^0.4.2",
"prismarine-auth": "^2.2.0",
"prismarine-chat": "^1.10.0",
"prismarine-nbt": "^2.5.0",
"prismarine-realms": "^1.2.0",
"protodef": "^1.8.0",
"protodef": "^1.17.0",
"readable-stream": "^4.1.0",
"uuid-1345": "^1.0.1",
"yggdrasil": "^1.4.0"
Expand Down
2 changes: 2 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Client extends EventEmitter {
this.hideErrors = hideErrors
this.closeTimer = null
const mcData = require('minecraft-data')(version)
this._supportFeature = mcData.supportFeature
this.state = states.HANDSHAKING
this._hasBundlePacket = mcData.supportFeature('hasBundlePacket')
}
Expand Down Expand Up @@ -137,6 +138,7 @@ class Client extends EventEmitter {
this.splitter.pipe(this.deserializer)
} else {
this.serializer.pipe(this.compressor)
if (globalThis.debugNMP) this.decompressor.on('data', (data) => { console.log('DES>', data.toString('hex')) })
this.decompressor.pipe(this.deserializer)
}

Expand Down
9 changes: 5 additions & 4 deletions src/client/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module.exports = function (client, options) {
})
})

client.on('message_header', (packet) => {
client.on('message_header', (packet) => { // [1.19.2]
updateAndValidateChat(packet.senderUuid, packet.previousSignature, packet.signature, packet.messageHash)

client._lastChatHistory.push({
Expand Down Expand Up @@ -369,13 +369,14 @@ module.exports = function (client, options) {

if (message.startsWith('/')) {
const command = message.slice(1)
if (mcData.supportFeature('useChatSessions')) {
if (mcData.supportFeature('useChatSessions')) { // 1.19.3+
const { acknowledged, acknowledgements } = getAcknowledgements()
client.write('chat_command', {
const canSign = client.profileKeys && client._session
client.write((mcData.supportFeature('seperateSignedChatCommandPacket') && canSign) ? 'chat_command_signed' : 'chat_command', {
command,
timestamp: options.timestamp,
salt: options.salt,
argumentSignatures: (client.profileKeys && client._session) ? signaturesForCommand(command, options.timestamp, options.salt, options.preview, acknowledgements) : [],
argumentSignatures: canSign ? signaturesForCommand(command, options.timestamp, options.salt, options.preview, acknowledgements) : [],
messageCount: client._lastSeenMessages.pending,
acknowledged
})
Expand Down
8 changes: 6 additions & 2 deletions src/client/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ module.exports = function (client, options) {
client.on('server_data', (packet) => {
client.serverFeatures = {
chatPreview: packet.previewsChat,
enforcesSecureChat: packet.enforcesSecureChat
enforcesSecureChat: packet.enforcesSecureChat // in LoginPacket v>=1.20.5
}
})

client.once('login', () => {
client.once('login', (packet) => {
if (packet.enforcesSecureChat) client.serverFeatures.enforcesSecureChat = packet.enforcesSecureChat
const mcData = require('minecraft-data')(client.version)
if (mcData.supportFeature('useChatSessions') && client.profileKeys && client.cipher && client.session.selectedProfile.id === client.uuid.replace(/-/g, '')) {
client._session = {
Expand Down Expand Up @@ -52,6 +53,9 @@ module.exports = function (client, options) {
client.write('configuration_acknowledged', {})
}
client.state = states.CONFIGURATION
client.on('select_known_packs', () => {
client.write('select_known_packs', { packs: [] })
})
// Server should send finish_configuration on its own right after sending the client a dimension codec
// for login (that has data about world height, world gen, etc) after getting a login success from client
client.once('finish_configuration', () => {
Expand Down
1 change: 1 addition & 0 deletions src/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function createServer (options = {}) {
server.onlineModeExceptions = Object.create(null)
server.favicon = favicon
server.options = options
server._supportFeature = mcData.supportFeature
options.registryCodec = options.registryCodec || mcData.registryCodec || mcData.loginPacket?.dimensionCodec

// The RSA keypair can take some time to generate
Expand Down
Loading

0 comments on commit cd84cae

Please sign in to comment.