baltica 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +4 -5
  2. package/dist/bridge/bridge-options.d.ts +8 -8
  3. package/dist/bridge/bridge-options.js +1 -0
  4. package/dist/bridge/bridge-player.d.ts +1 -1
  5. package/dist/bridge/bridge-player.js +2 -7
  6. package/dist/bridge/bridge.js +131 -38
  7. package/dist/client/client-data.js +17 -2
  8. package/dist/client/client-options.d.ts +22 -32
  9. package/dist/client/client-options.js +28 -15
  10. package/dist/client/client.d.ts +12 -1
  11. package/dist/client/client.js +115 -80
  12. package/dist/client/types/payload.d.ts +23 -1
  13. package/dist/client/types/payload.js +4 -5
  14. package/dist/client/types/skin/Skin.json +42 -28
  15. package/dist/network/auth.d.ts +2 -1
  16. package/dist/network/auth.js +17 -2
  17. package/dist/server/player.d.ts +1 -0
  18. package/dist/server/player.js +51 -38
  19. package/dist/server/server-options.d.ts +1 -4
  20. package/dist/server/server-options.js +1 -1
  21. package/dist/server/server.js +22 -4
  22. package/package.json +11 -11
  23. package/dist/network/packets/add-painting.d.ts +0 -9
  24. package/dist/network/packets/add-painting.js +0 -41
  25. package/dist/network/packets/client-cache-status.d.ts +0 -8
  26. package/dist/network/packets/client-cache-status.js +0 -37
  27. package/dist/network/packets/index.d.ts +0 -9
  28. package/dist/network/packets/index.js +0 -25
  29. package/dist/network/packets/level-chunk-packet.d.ts +0 -16
  30. package/dist/network/packets/level-chunk-packet.js +0 -67
  31. package/dist/network/packets/motion-predict-hints.d.ts +0 -6
  32. package/dist/network/packets/motion-predict-hints.js +0 -33
  33. package/dist/network/packets/set-default-gamemode.d.ts +0 -4
  34. package/dist/network/packets/set-default-gamemode.js +0 -25
  35. package/dist/network/packets/set-last-hurt-by.d.ts +0 -4
  36. package/dist/network/packets/set-last-hurt-by.js +0 -25
  37. package/dist/network/packets/update-block-sync.d.ts +0 -9
  38. package/dist/network/packets/update-block-sync.js +0 -45
  39. package/dist/network/packets/update-player-game-type.d.ts +0 -6
  40. package/dist/network/packets/update-player-game-type.js +0 -33
  41. package/dist/network/packets/update-subchunk-blocks.d.ts +0 -25
  42. package/dist/network/packets/update-subchunk-blocks.js +0 -83
package/README.md CHANGED
@@ -4,6 +4,10 @@
4
4
  <img src="https://raw.githubusercontent.com/SanctumTerra/Baltica/master/.extra/logo.png" alt="Baltica Logo" width="200"/>
5
5
  </p>
6
6
 
7
+ ---
8
+ **Supported Versions** `1.21.80` `1.21.70` `1.21.60` `1.21.50`
9
+ ---
10
+
7
11
  Baltica is a high-performance Minecraft Bedrock Edition networking toolkit built with TypeScript. It serves three main purposes:
8
12
  1. A powerful bridge/proxy that can modify, intercept, and manipulate network traffic between Minecraft Bedrock clients and servers
9
13
  2. A robust client library for creating Minecraft Bedrock bots and automated players
@@ -285,11 +289,6 @@ Baltica supports both Node.js and Bun runtimes, with Bun offering significant pe
285
289
  - Better packet processing performance
286
290
  - Improved concurrent connections handling
287
291
 
288
- To run with Bun:
289
- ```bash
290
- bun run start
291
- ```
292
-
293
292
  ## Contributing
294
293
 
295
294
  Contributions are welcome! Please feel free to submit a Pull Request.
@@ -1,21 +1,21 @@
1
1
  import type * as Protocol from "@serenityjs/protocol";
2
2
  import type { PacketNames } from "../client";
3
- import type { ClientCacheStatusPacket } from "../network/packets/client-cache-status";
4
3
  import { type ServerOptions } from "../server/server-options";
5
4
  export type BridgePlayerEvents = {
6
5
  [K in PacketNames as `clientbound-${K}`]: [
7
6
  packet: InstanceType<(typeof Protocol)[K]>,
8
- cancelled: boolean
7
+ eventStatus: {
8
+ cancelled: boolean;
9
+ modified: boolean;
10
+ }
9
11
  ];
10
12
  } & {
11
13
  [K in PacketNames as `serverbound-${K}`]: [
12
14
  packet: InstanceType<(typeof Protocol)[K]>,
13
- cancelled: boolean
14
- ];
15
- } & {
16
- "serverbound-ClientCacheStatusPacket": [
17
- packet: ClientCacheStatusPacket,
18
- cancelled: boolean
15
+ eventStatus: {
16
+ cancelled: boolean;
17
+ modified: boolean;
18
+ }
19
19
  ];
20
20
  };
21
21
  export type BridgeOptions = ServerOptions & {
@@ -8,5 +8,6 @@ exports.defaultBridgeOptions = {
8
8
  host: "127.0.0.1",
9
9
  port: 19132,
10
10
  },
11
+ levelName: "SanctumTerra Server",
11
12
  offline: false,
12
13
  };
@@ -1,4 +1,4 @@
1
- import type { LevelChunkPacket } from "../network/packets/level-chunk-packet";
1
+ import { type LevelChunkPacket } from "@serenityjs/protocol";
2
2
  import type { Client } from "../client";
3
3
  import { Emitter } from "../libs";
4
4
  import type { Player } from "../server";
@@ -10,16 +10,11 @@ class BridgePlayer extends libs_1.Emitter {
10
10
  this.player = player;
11
11
  this.postStartGame = false;
12
12
  this.levelChunkQueue = [];
13
- this.once("clientbound-StartGamePacket", (packet) => {
13
+ this.once("clientbound-StartGamePacket", (packet, eventStatus) => {
14
14
  this.postStartGame = true;
15
15
  for (const chunk of this.levelChunkQueue) {
16
16
  const eventName = "clientbound-LevelChunkPacket";
17
- this.emit(eventName, chunk, false);
18
- if ("binary" in packet) {
19
- packet.binary = [];
20
- }
21
- const newBuffer = chunk.serialize();
22
- this.player.send(newBuffer);
17
+ this.emit(eventName, chunk, { cancelled: false, modified: false });
23
18
  }
24
19
  });
25
20
  }
@@ -41,7 +41,6 @@ const raknet_1 = require("@sanctumterra/raknet");
41
41
  const protocol_1 = require("@serenityjs/protocol");
42
42
  const Protocol = __importStar(require("@serenityjs/protocol"));
43
43
  const client_1 = require("../client");
44
- const level_chunk_packet_1 = require("../network/packets/level-chunk-packet");
45
44
  const server_1 = require("../server");
46
45
  const bridge_options_1 = require("./bridge-options");
47
46
  const bridge_player_1 = require("./bridge-player");
@@ -60,9 +59,9 @@ class Bridge extends server_1.Server {
60
59
  initializePacketCache() {
61
60
  const CLIENT_CACHE_STATUS_ID = 129;
62
61
  this.packetClassCache.set(CLIENT_CACHE_STATUS_ID, protocol_1.ClientCacheStatusPacket);
63
- const levelChunkId = level_chunk_packet_1.LevelChunkPacket.id;
62
+ const levelChunkId = Protocol.LevelChunkPacket.id;
64
63
  if (levelChunkId !== undefined) {
65
- this.packetClassCache.set(levelChunkId, level_chunk_packet_1.LevelChunkPacket);
64
+ this.packetClassCache.set(levelChunkId, Protocol.LevelChunkPacket);
66
65
  }
67
66
  }
68
67
  getPacketClass(id, PacketClass) {
@@ -77,52 +76,110 @@ class Bridge extends server_1.Server {
77
76
  const id = (0, protocol_1.getPacketId)(buffer);
78
77
  const PacketClass = protocol_1.Packets[id];
79
78
  const packetName = PacketClass?.name ?? "ClientCacheStatusPacket";
79
+ console.log(packetName);
80
80
  const eventName = `${isClientbound ? "clientbound" : "serverbound"}-${packetName}`;
81
81
  if (!PacketClass && id !== 129) {
82
+ if (this.debugLog) {
83
+ raknet_1.Logger.info(`Passing through unknown packet ID: ${id}`);
84
+ }
82
85
  sender.send(buffer);
83
86
  return;
84
87
  }
85
88
  if (packetName === "LevelChunkPacket" && !player.postStartGame) {
86
- player.levelChunkQueue.push(new level_chunk_packet_1.LevelChunkPacket(buffer).deserialize());
89
+ try {
90
+ player.levelChunkQueue.push(new Protocol.LevelChunkPacket(buffer).deserialize());
91
+ }
92
+ catch (e) {
93
+ raknet_1.Logger.error("Failed to deserialize LevelChunkPacket for queueing", e);
94
+ sender.send(buffer);
95
+ }
96
+ return;
97
+ }
98
+ if (packetName === "ItemStackRequestPacket") {
99
+ if (this.debugLog) {
100
+ raknet_1.Logger.info(`Passing through ItemStackRequestPacket (ID: ${id}) without processing.`);
101
+ }
102
+ sender.send(buffer);
103
+ return;
104
+ }
105
+ const hasListeners = player.hasListeners(eventName);
106
+ const isClientCachePacket = packetName === "ClientCacheStatusPacket";
107
+ const needsProcessing = hasListeners || isClientCachePacket;
108
+ if (!needsProcessing) {
109
+ if (this.debugLog) {
110
+ raknet_1.Logger.info(`${isClientbound ? "Client -> BridgePlayer" : "BridgePlayer -> Client"} : ${packetName} (ID: ${id}) (No listeners/special handling, sending original)`);
111
+ }
112
+ sender.send(buffer);
87
113
  return;
88
114
  }
89
- if (!player.hasListeners(eventName) &&
90
- packetName !== "ClientCacheStatusPacket") {
115
+ const cacheKey = `${id}-${buffer.toString("hex")}`;
116
+ const cachedSerializedBuffer = this.packetSerializationCache.get(cacheKey);
117
+ if (cachedSerializedBuffer) {
118
+ if (this.debugLog) {
119
+ raknet_1.Logger.info(`${isClientbound ? "Client -> BridgePlayer" : "BridgePlayer -> Client"} : ${packetName} (ID: ${id}) (Sending cached serialized)`);
120
+ }
121
+ sender.send(cachedSerializedBuffer);
122
+ return;
123
+ }
124
+ const CachedPacketClass = this.getPacketClass(id, PacketClass);
125
+ if (!CachedPacketClass) {
126
+ raknet_1.Logger.warn(`Could not get packet class for ${packetName} (ID: ${id}) despite needing processing. Sending original.`);
91
127
  sender.send(buffer);
92
128
  return;
93
129
  }
130
+ let packet;
94
131
  try {
95
- const CachedPacketClass = this.getPacketClass(id, PacketClass);
96
- if (!CachedPacketClass) {
97
- sender.send(buffer);
132
+ packet = new CachedPacketClass(buffer).deserialize();
133
+ }
134
+ catch (e) {
135
+ raknet_1.Logger.error(`Failed to deserialize ${packetName} (ID: ${id}). Sending original buffer.`, e);
136
+ sender.send(buffer);
137
+ return;
138
+ }
139
+ if (packet instanceof protocol_1.ClientCacheStatusPacket) {
140
+ packet.enabled = false;
141
+ raknet_1.Logger.warn(`Modified and dropping ClientCacheStatusPacket (ID: ${id})`);
142
+ return;
143
+ }
144
+ const eventStatus = { cancelled: false, modified: false };
145
+ if (hasListeners) {
146
+ if (this.debugLog) {
147
+ raknet_1.Logger.info(`${isClientbound ? "Client -> BridgePlayer" : "BridgePlayer -> Client"} : ${packetName} (ID: ${id}) (Emitting event)`);
148
+ }
149
+ player.emit(eventName, packet, eventStatus);
150
+ if (eventStatus.cancelled) {
151
+ if (this.debugLog) {
152
+ raknet_1.Logger.info(`${isClientbound ? "Client -> BridgePlayer" : "BridgePlayer -> Client"} : ${packetName} (ID: ${id}) (Cancelled by listener)`);
153
+ }
98
154
  return;
99
155
  }
156
+ }
157
+ let bridgeMadeModifications = false;
158
+ if ("binary" in packet && packet.binary !== undefined) {
159
+ if (!Array.isArray(packet.binary) || packet.binary.length > 0) {
160
+ packet.binary = [];
161
+ bridgeMadeModifications = true;
162
+ }
163
+ }
164
+ const requiresSerialization = eventStatus.modified || bridgeMadeModifications;
165
+ if (requiresSerialization) {
100
166
  if (this.debugLog) {
101
- raknet_1.Logger.info(`${isClientbound ? "Client -> BridgePlayer" : "BridgePlayer -> Client"} : ${packetName}`);
167
+ raknet_1.Logger.info(`${isClientbound ? "Client -> BridgePlayer" : "BridgePlayer -> Client"} : ${packetName} (ID: ${id}) (Re-serializing after modification)`);
102
168
  }
103
- const cacheKey = `${id}-${buffer.toString("hex")}`;
104
- let newBuffer = this.packetSerializationCache.get(cacheKey);
105
- if (!newBuffer) {
106
- const packet = new CachedPacketClass(buffer).deserialize();
107
- if (packet instanceof protocol_1.ClientCacheStatusPacket) {
108
- packet.enabled = false;
109
- raknet_1.Logger.warn("Ignoring ClientCacheStatusPacket");
110
- return;
111
- }
112
- const cancelled = false;
113
- player.emit(eventName, packet, cancelled);
114
- if (cancelled)
115
- return;
116
- if ("binary" in packet) {
117
- packet.binary = [];
118
- }
119
- newBuffer = packet.serialize();
120
- this.packetSerializationCache.set(cacheKey, newBuffer);
169
+ try {
170
+ const newSerializedBuffer = packet.serialize();
171
+ this.packetSerializationCache.set(cacheKey, newSerializedBuffer);
172
+ sender.send(newSerializedBuffer);
173
+ }
174
+ catch (e) {
175
+ raknet_1.Logger.error(`Failed to serialize modified ${packetName} (ID: ${id}). Sending original buffer.`, e);
176
+ sender.send(buffer);
121
177
  }
122
- sender.send(newBuffer);
123
178
  }
124
- catch (e) {
125
- raknet_1.Logger.error(`Failed to process ${packetName}`, e);
179
+ else {
180
+ if (this.debugLog) {
181
+ raknet_1.Logger.info(`${isClientbound ? "Client -> BridgePlayer" : "BridgePlayer -> Client"} : ${packetName} (ID: ${id}) (Processed, not modified, sending original)`);
182
+ }
126
183
  sender.send(buffer);
127
184
  }
128
185
  }
@@ -142,8 +199,8 @@ class Bridge extends server_1.Server {
142
199
  const frame = new raknet_1.Frame();
143
200
  frame.orderChannel = 0;
144
201
  frame.payload = rakDisconnect.serialize();
145
- player.client.raknet.sendFrame(frame, raknet_1.Priority.Immediate);
146
- player.client.send(disconnect);
202
+ player.client?.raknet?.sendFrame(frame, raknet_1.Priority.Immediate);
203
+ player.client?.send(disconnect);
147
204
  }
148
205
  });
149
206
  }
@@ -163,14 +220,50 @@ class Bridge extends server_1.Server {
163
220
  });
164
221
  }
165
222
  onLogin(player) {
223
+ console.log("Creating Client");
224
+ const payload = player.player.data.payload;
225
+ console.log(this.options);
166
226
  const client = new client_1.Client({
167
227
  host: this.options.destination.host,
168
228
  port: this.options.destination.port,
169
229
  version: this.options.version,
170
230
  tokensFolder: "tokens",
171
- viewDistance: 2,
231
+ viewDistance: payload.MaxViewDistance,
172
232
  worker: true,
173
233
  offline: this.options.offline,
234
+ deviceOS: payload.DeviceOS,
235
+ skinData: {
236
+ AnimatedImageData: payload.AnimatedImageData,
237
+ ArmSize: payload.ArmSize,
238
+ SkinData: payload.SkinData,
239
+ TrustedSkin: payload.TrustedSkin,
240
+ CapeData: payload.CapeData,
241
+ CapeId: payload.CapeId,
242
+ CapeImageHeight: payload.CapeImageHeight,
243
+ CapeImageWidth: payload.CapeImageWidth,
244
+ CapeOnClassicSkin: payload.CapeOnClassicSkin,
245
+ PersonaPieces: payload.PersonaPieces,
246
+ PieceTintColors: payload.PieceTintColors,
247
+ PersonaSkin: payload.PersonaSkin,
248
+ PremiumSkin: payload.PremiumSkin,
249
+ SkinAnimationData: payload.SkinAnimationData,
250
+ SkinColor: payload.SkinColor,
251
+ SkinGeometryData: payload.SkinGeometryData,
252
+ SkinGeometryDataEngineVersion: payload.SkinGeometryDataEngineVersion,
253
+ SkinId: payload.SkinId,
254
+ SkinImageHeight: payload.SkinImageHeight,
255
+ SkinImageWidth: payload.SkinImageWidth,
256
+ SkinResourcePatch: payload.SkinResourcePatch,
257
+ },
258
+ loginOptions: {
259
+ CurrentInputMode: payload.CurrentInputMode,
260
+ DefaultInputMode: payload.DefaultInputMode,
261
+ DeviceModel: payload.DeviceModel,
262
+ },
263
+ platformType: payload.PlatformType,
264
+ memoryTier: payload.MemoryTier,
265
+ uiProfile: payload.UIProfile,
266
+ graphicsMode: payload.GraphicsMode,
174
267
  });
175
268
  console.log(this.options);
176
269
  player.client = client;
@@ -183,10 +276,10 @@ class Bridge extends server_1.Server {
183
276
  packet.enabled = false;
184
277
  client.send(packet.serialize());
185
278
  });
186
- player.once("serverbound-ResourcePackClientResponsePacket", () => {
187
- const packet = new protocol_1.ClientCacheStatusPacket();
188
- packet.enabled = false;
189
- player.player.send(packet.serialize());
279
+ player.once("serverbound-ResourcePackClientResponsePacket", (packet, eventStatus) => {
280
+ const responsePacket = new protocol_1.ClientCacheStatusPacket();
281
+ responsePacket.enabled = false;
282
+ player.player.send(responsePacket.serialize());
190
283
  });
191
284
  client.once("PlayStatusPacket", (packet) => {
192
285
  if (packet.status !== protocol_1.PlayStatus.LoginSuccess) {
@@ -41,6 +41,7 @@ const jose = __importStar(require("jose"));
41
41
  const node_crypto_1 = require("node:crypto");
42
42
  const login_data_1 = require("./types/login-data");
43
43
  const raknet_1 = require("@sanctumterra/raknet");
44
+ const client_options_1 = require("./client-options");
44
45
  const PUBLIC_KEY = "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAECRXueJeTDqNRRgJi/vlRufByu/2G0i2Ebt6YMar5QX/R0DIIyrJMcUpruK4QveTfJSTp3Shlq4Gk34cD/4GUWwkv0DVuzeuB+tXija7HBxii03NHDbPAD0AKnLr2wdAp";
45
46
  const algorithm = "ES384";
46
47
  const curve = "secp384r1";
@@ -56,7 +57,18 @@ class ClientData {
56
57
  const loginPacket = new protocol_1.LoginPacket();
57
58
  const chain = [this.loginData.clientIdentityChain, ...this.accessToken];
58
59
  const userChain = this.loginData.clientUserChain;
59
- const encodedChain = JSON.stringify({ chain });
60
+ let encodedChain = "";
61
+ if ((0, client_options_1.versionHigherThan)(this.client.options.version, "1.21.80")) {
62
+ const certificate = JSON.stringify({ chain });
63
+ encodedChain = JSON.stringify({
64
+ AuthenticationType: 2,
65
+ Certificate: certificate,
66
+ Token: "",
67
+ });
68
+ }
69
+ else {
70
+ encodedChain = JSON.stringify({ chain });
71
+ }
60
72
  loginPacket.protocol = this.client.protocol;
61
73
  loginPacket.tokens = new protocol_1.LoginTokens(userChain, encodedChain);
62
74
  return loginPacket;
@@ -105,7 +117,10 @@ class ClientData {
105
117
  }
106
118
  async createClientUserChain(privateKey) {
107
119
  const { clientX509 } = this.loginData;
108
- const customPayload = this.client.options.skinData || {};
120
+ // Partial Payload
121
+ const customPayload = {
122
+ ...this.client.options.skinData,
123
+ };
109
124
  const payload = {
110
125
  ...this.payload,
111
126
  ...customPayload,
@@ -1,14 +1,13 @@
1
1
  import { CompressionMethod, InputMode } from "@serenityjs/protocol";
2
2
  import type * as Protocol from "@serenityjs/protocol";
3
- import type { ClientCacheStatusPacket } from "../network/packets/client-cache-status";
4
3
  import type { Advertisement } from "@sanctumterra/raknet";
5
- import { AddPaintingPacket, UpdateSubchunkBlocksPacket, MotionPredictHintsPacket, SetLastHurtByPacket, SetDefaultGamemodePacket, UpdatePlayerGameTypePacket, UpdateBlockSyncPacket } from "../network/packets";
6
- import { LevelChunkPacket } from "../network/packets/level-chunk-packet";
4
+ import type { SkinData } from "./types/payload";
7
5
  export declare enum ProtocolList {
8
6
  "1.21.50" = 766,
9
7
  "1.21.60" = 776,
10
8
  "1.21.70" = 786,
11
- "1.21.80" = 800
9
+ "1.21.80" = 800,
10
+ "1.21.90" = 818
12
11
  }
13
12
  export declare enum DeviceOS {
14
13
  Undefined = 0,
@@ -28,6 +27,20 @@ export declare enum DeviceOS {
28
27
  WindowsPhone = 14,
29
28
  Linux = 15
30
29
  }
30
+ /**
31
+ * Checks if client version is higher than the specified version
32
+ * @param clientVersion The client version to check
33
+ * @param targetVersion The version to compare against
34
+ * @returns True if client version is higher than targetVersion
35
+ */
36
+ export declare function versionHigherThan(clientVersion: keyof typeof ProtocolList, targetVersion: keyof typeof ProtocolList): boolean;
37
+ /**
38
+ * Checks if client version is lower than the specified version
39
+ * @param clientVersion The client version to check
40
+ * @param targetVersion The version to compare against
41
+ * @returns True if client version is lower than targetVersion
42
+ */
43
+ export declare function versionLowerThan(clientVersion: keyof typeof ProtocolList, targetVersion: keyof typeof ProtocolList): boolean;
31
44
  type LoginPacketOptions = {
32
45
  DeviceModel: string;
33
46
  CurrentInputMode: InputMode;
@@ -44,11 +57,15 @@ type ClientOptions = {
44
57
  username: string;
45
58
  tokensFolder: string;
46
59
  viewDistance: number;
47
- skinData: object | undefined;
60
+ skinData: SkinData | undefined;
48
61
  offline: boolean;
49
62
  worker: boolean;
50
63
  loginOptions: LoginPacketOptions;
51
64
  betaAuth: boolean;
65
+ platformType: number;
66
+ memoryTier: number;
67
+ uiProfile: number;
68
+ graphicsMode: number;
52
69
  };
53
70
  declare const defaultClientOptions: ClientOptions;
54
71
  type PacketNames = {
@@ -58,35 +75,8 @@ type ClientEvents = {
58
75
  [K in PacketNames]: [packet: InstanceType<(typeof Protocol)[K]>];
59
76
  } & {
60
77
  session: [];
61
- ClientCacheStatusPacket: [
62
- packet: InstanceType<typeof ClientCacheStatusPacket>
63
- ];
64
- UpdateSubchunkBlocksPacket: [
65
- packet: InstanceType<typeof UpdateSubchunkBlocksPacket>
66
- ];
67
- MotionPredictHintsPacket: [
68
- packet: InstanceType<typeof MotionPredictHintsPacket>
69
- ];
70
- SetLastHurtByPacket: [packet: InstanceType<typeof SetLastHurtByPacket>];
71
- SetDefaultGamemodePacket: [
72
- packet: InstanceType<typeof SetDefaultGamemodePacket>
73
- ];
74
- UpdatePlayerGameTypePacket: [
75
- packet: InstanceType<typeof UpdatePlayerGameTypePacket>
76
- ];
77
- UpdateBlockSyncPacket: [packet: InstanceType<typeof UpdateBlockSyncPacket>];
78
78
  } & {
79
79
  packet: [packet: InstanceType<(typeof Protocol)[PacketNames]>];
80
80
  connect: [packet: Advertisement];
81
81
  };
82
82
  export { type ClientOptions, defaultClientOptions, type ClientEvents, type PacketNames, };
83
- export declare const ExtraPackets: {
84
- 58: typeof LevelChunkPacket;
85
- 22: typeof AddPaintingPacket;
86
- 172: typeof UpdateSubchunkBlocksPacket;
87
- 157: typeof MotionPredictHintsPacket;
88
- 96: typeof SetLastHurtByPacket;
89
- 105: typeof SetDefaultGamemodePacket;
90
- 151: typeof UpdatePlayerGameTypePacket;
91
- 110: typeof UpdateBlockSyncPacket;
92
- };
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExtraPackets = exports.defaultClientOptions = exports.DeviceOS = exports.ProtocolList = void 0;
3
+ exports.defaultClientOptions = exports.DeviceOS = exports.ProtocolList = void 0;
4
+ exports.versionHigherThan = versionHigherThan;
5
+ exports.versionLowerThan = versionLowerThan;
4
6
  const protocol_1 = require("@serenityjs/protocol");
5
- const packets_1 = require("../network/packets");
6
- const level_chunk_packet_1 = require("../network/packets/level-chunk-packet");
7
7
  var ProtocolList;
8
8
  (function (ProtocolList) {
9
9
  ProtocolList[ProtocolList["1.21.50"] = 766] = "1.21.50";
10
10
  ProtocolList[ProtocolList["1.21.60"] = 776] = "1.21.60";
11
11
  ProtocolList[ProtocolList["1.21.70"] = 786] = "1.21.70";
12
12
  ProtocolList[ProtocolList["1.21.80"] = 800] = "1.21.80";
13
+ ProtocolList[ProtocolList["1.21.90"] = 818] = "1.21.90";
13
14
  })(ProtocolList || (exports.ProtocolList = ProtocolList = {}));
14
15
  var DeviceOS;
15
16
  (function (DeviceOS) {
@@ -30,6 +31,24 @@ var DeviceOS;
30
31
  DeviceOS[DeviceOS["WindowsPhone"] = 14] = "WindowsPhone";
31
32
  DeviceOS[DeviceOS["Linux"] = 15] = "Linux";
32
33
  })(DeviceOS || (exports.DeviceOS = DeviceOS = {}));
34
+ /**
35
+ * Checks if client version is higher than the specified version
36
+ * @param clientVersion The client version to check
37
+ * @param targetVersion The version to compare against
38
+ * @returns True if client version is higher than targetVersion
39
+ */
40
+ function versionHigherThan(clientVersion, targetVersion) {
41
+ return ProtocolList[clientVersion] > ProtocolList[targetVersion];
42
+ }
43
+ /**
44
+ * Checks if client version is lower than the specified version
45
+ * @param clientVersion The client version to check
46
+ * @param targetVersion The version to compare against
47
+ * @returns True if client version is lower than targetVersion
48
+ */
49
+ function versionLowerThan(clientVersion, targetVersion) {
50
+ return ProtocolList[clientVersion] < ProtocolList[targetVersion];
51
+ }
33
52
  const defaultClientOptions = {
34
53
  host: "127.0.0.1",
35
54
  port: 19132,
@@ -37,7 +56,7 @@ const defaultClientOptions = {
37
56
  compressionMethod: protocol_1.CompressionMethod.Zlib,
38
57
  compressionLevel: 7,
39
58
  deviceOS: DeviceOS.NintendoSwitch,
40
- version: "1.21.80",
59
+ version: "1.21.90",
41
60
  username: "SanctumTerra",
42
61
  tokensFolder: "tokens",
43
62
  viewDistance: 10,
@@ -45,20 +64,14 @@ const defaultClientOptions = {
45
64
  offline: false,
46
65
  worker: false,
47
66
  loginOptions: {
48
- DeviceModel: "SwimmingPool",
67
+ DeviceModel: "Bean Bag Chair",
49
68
  CurrentInputMode: protocol_1.InputMode.GamePad,
50
69
  DefaultInputMode: protocol_1.InputMode.GamePad,
51
70
  },
52
71
  betaAuth: false,
72
+ platformType: 2,
73
+ memoryTier: 2,
74
+ uiProfile: 0,
75
+ graphicsMode: 0,
53
76
  };
54
77
  exports.defaultClientOptions = defaultClientOptions;
55
- exports.ExtraPackets = {
56
- [58]: level_chunk_packet_1.LevelChunkPacket,
57
- [22]: packets_1.AddPaintingPacket,
58
- [172]: packets_1.UpdateSubchunkBlocksPacket,
59
- [157]: packets_1.MotionPredictHintsPacket,
60
- [96]: packets_1.SetLastHurtByPacket,
61
- [105]: packets_1.SetDefaultGamemodePacket,
62
- [151]: packets_1.UpdatePlayerGameTypePacket,
63
- [110]: packets_1.UpdateBlockSyncPacket,
64
- };
@@ -25,19 +25,30 @@ declare class Client extends Emitter<ClientEvents> {
25
25
  runtimeEntityId: bigint;
26
26
  cancelPastLogin: boolean;
27
27
  constructor(options: Partial<ClientOptions>);
28
+ private initializeSession;
28
29
  connect(): Promise<[Advertisement, StartGamePacket]>;
30
+ private waitForSessionReady;
31
+ private waitForConnection;
29
32
  private handleStartGamePacket;
33
+ private requestChunkRadius;
30
34
  private handleEncapsulated;
31
35
  private sendPacket;
32
36
  send(packet: DataPacket | Buffer): void;
33
37
  queue(packet: DataPacket | Buffer): void;
34
38
  /** Already decompressed packets */
35
39
  processPacket(buffer: Buffer): void;
36
- listen(): void;
40
+ private setupEventListeners;
41
+ private setupConnectionListeners;
42
+ private handleRaknetConnect;
43
+ private setupPacketListeners;
44
+ private handleNetworkSettingsPacket;
45
+ private handleServerHandshake;
37
46
  private handlePlayStatusPacket;
47
+ private completePlayerSpawn;
38
48
  private handleResourcePacksInfoPacket;
39
49
  startEncryption(iv: Buffer): void;
40
50
  disconnect(): void;
51
+ private cleanup;
41
52
  sendMessage(text: string): void;
42
53
  }
43
54
  export { Client };