-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add protocol ID map, filter parsed native packets.
We now provide an array of accepted clientbound IDs to the native connection module when creating a connection. This reduces JavaScript<->native communication considerably.
- Loading branch information
Showing
5 changed files
with
165 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { protocolMap } from '../utils' | ||
|
||
const generateIdFunction = | ||
(ids: Array<[number, number | null]>) => (protocolVersion: number) => { | ||
for (const [version, id] of ids) { | ||
if (version <= protocolVersion) return id | ||
} | ||
return null | ||
} | ||
|
||
const packetIds = { | ||
// Clientbound (login) | ||
CLIENTBOUND_SET_COMPRESSION: generateIdFunction([ | ||
[protocolMap['1.16.4'], 0x03] | ||
]), | ||
CLIENTBOUND_LOGIN_SUCCESS: generateIdFunction([ | ||
[protocolMap['1.16.4'], 0x02] | ||
]), | ||
CLIENTBOUND_LOGIN_PLUGIN_REQUEST: generateIdFunction([ | ||
[protocolMap['1.16.4'], 0x04] | ||
]), | ||
CLIENTBOUND_ENCRYPTION_REQUEST: generateIdFunction([ | ||
[protocolMap['1.16.4'], 0x01] | ||
]), | ||
CLIENTBOUND_DISCONNECT_LOGIN: generateIdFunction([ | ||
[protocolMap['1.16.4'], 0x00] | ||
]), | ||
|
||
// Clientbound (play) | ||
CLIENTBOUND_KEEP_ALIVE: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x20], | ||
[protocolMap['1.19'], 0x1e], | ||
[protocolMap['1.17'], 0x21], | ||
[protocolMap['1.16.4'], 0x1f] | ||
]), | ||
CLIENTBOUND_DISCONNECT_PLAY: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x19], | ||
[protocolMap['1.19'], 0x17], | ||
[protocolMap['1.17'], 0x1a], | ||
[protocolMap['1.16.4'], 0x19] | ||
]), | ||
CLIENTBOUND_LOGIN_PLAY: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x25], | ||
[protocolMap['1.19'], 0x23], | ||
[protocolMap['1.17'], 0x26], | ||
[protocolMap['1.16.4'], 0x24] | ||
]), | ||
CLIENTBOUND_RESPAWN: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x3e], | ||
[protocolMap['1.19'], 0x3b], | ||
[protocolMap['1.17'], 0x3d], | ||
[protocolMap['1.16.4'], 0x39] | ||
]), | ||
CLIENTBOUND_UPDATE_HEALTH: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x55], | ||
[protocolMap['1.17'], 0x52], | ||
[protocolMap['1.16.4'], 0x49] | ||
]), | ||
CLIENTBOUND_DEATH_COMBAT_EVENT: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x36], | ||
[protocolMap['1.19'], 0x33], | ||
[protocolMap['1.17'], 0x35], | ||
[protocolMap['1.16.4'], 0x31] | ||
]), | ||
CLIENTBOUND_OPEN_WINDOW: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x2d], | ||
[protocolMap['1.19'], 0x2b], | ||
[protocolMap['1.16.4'], 0x2e] | ||
]), | ||
CLIENTBOUND_CHAT_MESSAGE: generateIdFunction([ | ||
[protocolMap['1.19'], null], | ||
[protocolMap['1.17'], 0x0f], | ||
[protocolMap['1.16.4'], 0x0e] | ||
]), | ||
CLIENTBOUND_PLAYER_CHAT_MESSAGE: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x33], | ||
[protocolMap['1.19'], 0x30] | ||
]), | ||
CLIENTBOUND_SYSTEM_CHAT_MESSAGE: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x62], | ||
[protocolMap['1.19'], 0x5f] | ||
]), | ||
|
||
// Serverbound (play) | ||
SERVERBOUND_KEEP_ALIVE: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x12], | ||
[protocolMap['1.19'], 0x11], | ||
[protocolMap['1.17'], 0x0f], | ||
[protocolMap['1.16.4'], 0x10] | ||
]), | ||
SERVERBOUND_CLOSE_WINDOW: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x0c], | ||
[protocolMap['1.19'], 0x0b], | ||
[protocolMap['1.17'], 0x09], | ||
[protocolMap['1.16.4'], 0x0a] | ||
]), | ||
SERVERBOUND_CLIENT_SETTINGS: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x08], | ||
[protocolMap['1.19'], 0x07], | ||
[protocolMap['1.16.4'], 0x05] | ||
]), | ||
SERVERBOUND_CLIENT_STATUS: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x07], | ||
[protocolMap['1.19'], 0x06], | ||
[protocolMap['1.16.4'], 0x04] | ||
]), | ||
SERVERBOUND_CHAT_MESSAGE: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x05], | ||
[protocolMap['1.19'], 0x04], | ||
[protocolMap['1.16.4'], 0x03] | ||
]), | ||
SERVERBOUND_CHAT_COMMAND: generateIdFunction([ | ||
[protocolMap['1.19.1'], 0x04], | ||
[protocolMap['1.19'], 0x03], | ||
[protocolMap['1.16.4'], null] | ||
]) | ||
} | ||
|
||
export default packetIds |
Oops, something went wrong.