@vaitosoi/minejs 0.6.0 → 0.6.1
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.
- package/README.md +23 -11
- package/assets/minecraft/26.2/packets.json +0 -12
- package/assets/minecraft/26.3/packets.json +228 -38
- package/dist/binary/encoder.d.ts.map +1 -1
- package/dist/binary/encoder.js +4 -4
- package/dist/binary/encoder.js.map +1 -1
- package/dist/client/client.d.ts +127 -28
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +108 -27
- package/dist/client/client.js.map +1 -1
- package/dist/net/tcp.d.ts +0 -7
- package/dist/net/tcp.d.ts.map +1 -1
- package/dist/net/tcp.js +12 -18
- package/dist/net/tcp.js.map +1 -1
- package/dist/packet/listener.d.ts +1 -1
- package/dist/packet/listener.d.ts.map +1 -1
- package/dist/packet/listener.js +142 -55
- package/dist/packet/listener.js.map +1 -1
- package/dist/packet/sender.d.ts +2 -1
- package/dist/packet/sender.d.ts.map +1 -1
- package/dist/packet/sender.js +17 -6
- package/dist/packet/sender.js.map +1 -1
- package/dist/physics/aabb.d.ts.map +1 -1
- package/dist/physics/aabb.js +10 -2
- package/dist/physics/aabb.js.map +1 -1
- package/dist/physics/direction.js +2 -2
- package/dist/physics/direction.js.map +1 -1
- package/dist/version/codec.d.ts.map +1 -1
- package/dist/version/codec.js +38 -0
- package/dist/version/codec.js.map +1 -1
- package/dist/version/registry.d.ts +6 -1
- package/dist/version/registry.d.ts.map +1 -1
- package/dist/version/registry.js +26 -3
- package/dist/version/registry.js.map +1 -1
- package/dist/world/block.d.ts +44 -2
- package/dist/world/block.d.ts.map +1 -1
- package/dist/world/block.js +61 -21
- package/dist/world/block.js.map +1 -1
- package/dist/world/entity.d.ts +3 -0
- package/dist/world/entity.d.ts.map +1 -1
- package/dist/world/entity.js +3 -0
- package/dist/world/entity.js.map +1 -1
- package/dist/world/state.d.ts +3 -0
- package/dist/world/state.d.ts.map +1 -1
- package/dist/world/state.js +9 -0
- package/dist/world/state.js.map +1 -1
- package/package.json +2 -2
- package/src/binary/encoder.ts +5 -6
- package/src/client/client.ts +174 -51
- package/src/net/tcp.ts +12 -18
- package/src/packet/listener.ts +172 -70
- package/src/packet/sender.ts +18 -7
- package/src/physics/aabb.ts +11 -2
- package/src/physics/direction.ts +2 -2
- package/src/version/codec.ts +32 -0
- package/src/version/registry.ts +35 -5
- package/src/world/block.ts +64 -22
- package/src/world/entity.ts +3 -0
- package/src/world/state.ts +10 -0
- package/test/client/index.ts +13 -6
package/src/world/entity.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { AABB } from "../physics/aabb";
|
|
2
2
|
import { SharedState } from "./state";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* This class is for managing entities
|
|
6
|
+
*/
|
|
4
7
|
export class EntitiesManager {
|
|
5
8
|
/**
|
|
6
9
|
* Split chunks into 16x16x16 sections, so each chunk sections will contain a set of entities
|
package/src/world/state.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { MessageLink } from "../message/link";
|
|
|
7
7
|
import { SignatureCache } from "../message/sigCache";
|
|
8
8
|
import { CacheImplementation, LRUCache } from "../base/cache";
|
|
9
9
|
import { Container, Slot } from "./container";
|
|
10
|
+
import { ProtocolVersionMapping } from "../version/registry";
|
|
10
11
|
|
|
11
12
|
export interface Server {
|
|
12
13
|
knownPacks?: ServerKnownPack
|
|
@@ -186,6 +187,7 @@ export class SharedState {
|
|
|
186
187
|
public decipher: Decipheriv | undefined = undefined;
|
|
187
188
|
public useEncryption: boolean = false;
|
|
188
189
|
public sessionID: Buffer | undefined = undefined;
|
|
190
|
+
public sequence: number = 0;
|
|
189
191
|
|
|
190
192
|
public server: Server | undefined = undefined;
|
|
191
193
|
public registry: Record<string, ServerRegistryEntry[]> | undefined = undefined;
|
|
@@ -251,6 +253,7 @@ export class SharedState {
|
|
|
251
253
|
this.player = undefined as any;
|
|
252
254
|
this.messageCount = 0;
|
|
253
255
|
this.openingContainer = undefined as any;
|
|
256
|
+
this.sequence = 0;
|
|
254
257
|
|
|
255
258
|
if (this.clientOptions.shouldVerifyMessageSignature)
|
|
256
259
|
this.messageSignatureCache = SignatureCache.default();
|
|
@@ -269,6 +272,10 @@ export class SharedState {
|
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
274
|
|
|
275
|
+
public getProtocolId() {
|
|
276
|
+
return ProtocolVersionMapping[this.clientOptions.version]!;
|
|
277
|
+
}
|
|
278
|
+
|
|
272
279
|
public getSignature() {
|
|
273
280
|
if (this.publicKey && this.signature)
|
|
274
281
|
return {
|
|
@@ -277,6 +284,9 @@ export class SharedState {
|
|
|
277
284
|
};
|
|
278
285
|
throw new AuthRelatedNotFound("public key and signature");
|
|
279
286
|
}
|
|
287
|
+
public nextSequence() {
|
|
288
|
+
return ++this.sequence;
|
|
289
|
+
}
|
|
280
290
|
|
|
281
291
|
private async fetchSignature() {
|
|
282
292
|
if (!this.authClient)
|
package/test/client/index.ts
CHANGED
|
@@ -13,9 +13,10 @@ const client = new Client({
|
|
|
13
13
|
"add_entity", "remove_entities", "bundle_delimiter",
|
|
14
14
|
"entity_position_sync", "update_attributes",
|
|
15
15
|
"move_player_pos", "move_player_pos_rot", "move_player_rot",
|
|
16
|
-
"player_chat", "keep_alive", "entity_event", "tab_list"
|
|
16
|
+
"player_chat", "keep_alive", "entity_event", "tab_list",
|
|
17
|
+
"block_event"
|
|
17
18
|
],
|
|
18
|
-
ignoreTCPPacketLogs: [0, 83, 54, 101, 1, 99, 53, 35, 131, 113, 102, 44, 56, 65, 34, 77, 122]
|
|
19
|
+
ignoreTCPPacketLogs: [0, 83, 54, 101, 1, 99, 53, 35, 131, 113, 102, 44, 56, 65, 34, 77, 122, 7, 46]
|
|
19
20
|
},
|
|
20
21
|
loadRegistry: false,
|
|
21
22
|
// auth: {
|
|
@@ -74,18 +75,18 @@ client.on("message", async (message) => {
|
|
|
74
75
|
case "at": {
|
|
75
76
|
const [, x, y, z] = args.map(val => parseInt(val)) as [any, number, number, number];
|
|
76
77
|
console.time("get_block");
|
|
77
|
-
const state = client.
|
|
78
|
-
console.timeEnd("get_block");
|
|
78
|
+
const state = client.getBlock(x, y, z);
|
|
79
|
+
console.timeEnd("get_block");
|
|
79
80
|
if (state) {
|
|
80
81
|
console.dir(state);
|
|
81
82
|
client.chat(state!.owner.type);
|
|
82
|
-
} else
|
|
83
|
+
} else
|
|
83
84
|
client.chat("no block");
|
|
84
85
|
break;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
case "open": {
|
|
88
|
-
const [, x, y, z] = args.map(val =>
|
|
89
|
+
const [, x, y, z] = args.map(val => Number(val)) as [any, number, number, number];
|
|
89
90
|
const success = client.openBlock(x, y, z);
|
|
90
91
|
if (success) client.chat("opening");
|
|
91
92
|
else client.chat("failed");
|
|
@@ -104,5 +105,11 @@ client.on("message", async (message) => {
|
|
|
104
105
|
case "exit":
|
|
105
106
|
client.disconnect();
|
|
106
107
|
break;
|
|
108
|
+
|
|
109
|
+
case "pos": {
|
|
110
|
+
const { x, y, z } = client.getPosition();
|
|
111
|
+
client.chat(`XYZ: ${x} ${y} ${z}`);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
107
114
|
}
|
|
108
115
|
});
|