@vaitosoi/minejs 0.2.2 → 0.4.0
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 +1 -1
- package/assets/minecraft/26.2/packets.json +4758 -0
- package/dist/base/buffer.d.ts +2 -0
- package/dist/base/buffer.d.ts.map +1 -0
- package/dist/base/buffer.js +12 -0
- package/dist/base/buffer.js.map +1 -0
- package/dist/base/error.d.ts +59 -3
- package/dist/base/error.d.ts.map +1 -1
- package/dist/base/error.js +123 -7
- package/dist/base/error.js.map +1 -1
- package/dist/base/http.d.ts +2 -0
- package/dist/base/http.d.ts.map +1 -0
- package/dist/base/http.js +14 -0
- package/dist/base/http.js.map +1 -0
- package/dist/base/math.d.ts +22 -1
- package/dist/base/math.d.ts.map +1 -1
- package/dist/base/math.js +49 -2
- package/dist/base/math.js.map +1 -1
- package/dist/base/typing.d.ts +7 -1
- package/dist/base/typing.d.ts.map +1 -1
- package/dist/client/auth.d.ts +41 -7
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +96 -39
- package/dist/client/auth.js.map +1 -1
- package/dist/client/client.d.ts +73 -17
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +111 -44
- package/dist/client/client.js.map +1 -1
- package/dist/client/tcp.d.ts +17 -206
- package/dist/client/tcp.d.ts.map +1 -1
- package/dist/client/tcp.js +37 -715
- package/dist/client/tcp.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/message/link.d.ts +10 -0
- package/dist/message/link.d.ts.map +1 -0
- package/dist/message/link.js +22 -0
- package/dist/message/link.js.map +1 -0
- package/dist/message/sigCache.d.ts +13 -0
- package/dist/message/sigCache.d.ts.map +1 -0
- package/dist/message/sigCache.js +26 -0
- package/dist/message/sigCache.js.map +1 -0
- package/dist/{translator → packet}/decoder.d.ts +14 -1
- package/dist/packet/decoder.d.ts.map +1 -0
- package/dist/{translator → packet}/decoder.js +24 -3
- package/dist/packet/decoder.js.map +1 -0
- package/dist/packet/dispatcher.d.ts +53 -0
- package/dist/packet/dispatcher.d.ts.map +1 -0
- package/dist/packet/dispatcher.js +738 -0
- package/dist/packet/dispatcher.js.map +1 -0
- package/dist/{translator → packet}/encoder.d.ts +4 -3
- package/dist/packet/encoder.d.ts.map +1 -0
- package/dist/{translator → packet}/encoder.js +18 -7
- package/dist/packet/encoder.js.map +1 -0
- package/dist/packet/static.d.ts.map +1 -0
- package/dist/packet/static.js.map +1 -0
- package/dist/{base → physics}/aabb.d.ts +2 -2
- package/dist/physics/aabb.d.ts.map +1 -0
- package/dist/{base → physics}/aabb.js +5 -5
- package/dist/physics/aabb.js.map +1 -0
- package/dist/physics/direction.d.ts.map +1 -0
- package/dist/physics/direction.js.map +1 -0
- package/dist/{base → physics}/player.d.ts +25 -28
- package/dist/physics/player.d.ts.map +1 -0
- package/dist/{base → physics}/player.js +81 -68
- package/dist/physics/player.js.map +1 -0
- package/dist/version/codec.d.ts +18 -0
- package/dist/version/codec.d.ts.map +1 -0
- package/dist/version/codec.js +235 -0
- package/dist/version/codec.js.map +1 -0
- package/dist/version/registry.d.ts +236 -0
- package/dist/version/registry.d.ts.map +1 -0
- package/dist/version/registry.js +284 -0
- package/dist/version/registry.js.map +1 -0
- package/dist/{base → world}/block.d.ts +5 -5
- package/dist/world/block.d.ts.map +1 -0
- package/dist/{base → world}/block.js +13 -13
- package/dist/world/block.js.map +1 -0
- package/dist/{base → world}/entity.d.ts +4 -4
- package/dist/world/entity.d.ts.map +1 -0
- package/dist/{base → world}/entity.js +6 -6
- package/dist/world/entity.js.map +1 -0
- package/dist/world/state.d.ts +175 -0
- package/dist/world/state.d.ts.map +1 -0
- package/dist/world/state.js +163 -0
- package/dist/world/state.js.map +1 -0
- package/dist/world/tick.d.ts.map +1 -0
- package/dist/world/tick.js.map +1 -0
- package/package.json +7 -2
- package/src/base/buffer.ts +12 -0
- package/src/base/error.ts +93 -4
- package/src/base/http.ts +10 -0
- package/src/base/math.ts +55 -3
- package/src/base/typing.ts +9 -1
- package/src/client/auth.ts +130 -52
- package/src/client/client.ts +182 -50
- package/src/client/tcp.ts +45 -967
- package/src/index.ts +12 -12
- package/src/message/link.ts +17 -0
- package/src/message/sigCache.ts +25 -0
- package/src/{translator → packet}/decoder.ts +24 -3
- package/src/packet/dispatcher.ts +919 -0
- package/src/{translator → packet}/encoder.ts +20 -9
- package/src/{base → physics}/aabb.ts +5 -5
- package/src/{base → physics}/player.ts +106 -65
- package/src/version/codec.ts +248 -0
- package/src/version/registry.ts +328 -0
- package/src/{base → world}/block.ts +12 -11
- package/src/{base → world}/entity.ts +5 -5
- package/src/world/state.ts +300 -0
- package/test/adapter/index.ts +14 -0
- package/test/client/index.ts +28 -21
- package/test/json/index.ts +3 -0
- package/dist/base/aabb.d.ts.map +0 -1
- package/dist/base/aabb.js.map +0 -1
- package/dist/base/block.d.ts.map +0 -1
- package/dist/base/block.js.map +0 -1
- package/dist/base/direction.d.ts.map +0 -1
- package/dist/base/direction.js.map +0 -1
- package/dist/base/entity.d.ts.map +0 -1
- package/dist/base/entity.js.map +0 -1
- package/dist/base/player.d.ts.map +0 -1
- package/dist/base/player.js.map +0 -1
- package/dist/base/registry.d.ts +0 -50
- package/dist/base/registry.d.ts.map +0 -1
- package/dist/base/registry.js +0 -89
- package/dist/base/registry.js.map +0 -1
- package/dist/base/tick.d.ts.map +0 -1
- package/dist/base/tick.js.map +0 -1
- package/dist/translator/decoder.d.ts.map +0 -1
- package/dist/translator/decoder.js.map +0 -1
- package/dist/translator/encoder.d.ts.map +0 -1
- package/dist/translator/encoder.js.map +0 -1
- package/dist/translator/static.d.ts.map +0 -1
- package/dist/translator/static.js.map +0 -1
- package/src/base/registry.ts +0 -87
- /package/assets/minecraft/{blocks.json → 26.2/blocks.json} +0 -0
- /package/assets/minecraft/{entities.json → 26.2/entities.json} +0 -0
- /package/dist/{translator → packet}/static.d.ts +0 -0
- /package/dist/{translator → packet}/static.js +0 -0
- /package/dist/{base → physics}/direction.d.ts +0 -0
- /package/dist/{base → physics}/direction.js +0 -0
- /package/dist/{base → world}/tick.d.ts +0 -0
- /package/dist/{base → world}/tick.js +0 -0
- /package/src/{translator → packet}/static.ts +0 -0
- /package/src/{base → physics}/direction.ts +0 -0
- /package/src/{base → world}/tick.ts +0 -0
package/src/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export * from "./base/aabb";
|
|
2
1
|
export * from "./base/bitset";
|
|
3
|
-
export * from "./base/block";
|
|
4
|
-
export * from "./base/block";
|
|
5
|
-
export * from "./base/direction";
|
|
6
|
-
export * from "./base/entity";
|
|
7
2
|
export * from "./base/error";
|
|
8
3
|
export * from "./base/event";
|
|
9
4
|
export * from "./base/math";
|
|
10
|
-
export * from "./base/player";
|
|
11
|
-
export * from "./base/registry";
|
|
12
|
-
export * from "./base/tick";
|
|
13
5
|
export * from "./base/typing";
|
|
14
6
|
export * from "./client/auth";
|
|
15
7
|
export * from "./client/client";
|
|
16
|
-
export * from "./client/static";
|
|
17
8
|
export * from "./client/tcp";
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
20
|
-
export * from "./
|
|
9
|
+
export * from "./packet/decoder";
|
|
10
|
+
export * from "./packet/encoder";
|
|
11
|
+
export * from "./packet/dispatcher";
|
|
12
|
+
export * from "./physics/aabb";
|
|
13
|
+
export * from "./physics/direction";
|
|
14
|
+
export * from "./physics/player";
|
|
15
|
+
export * from "./version/codec";
|
|
16
|
+
export * from "./version/registry";
|
|
17
|
+
export * from "./world/block";
|
|
18
|
+
export * from "./world/entity";
|
|
19
|
+
export * from "./world/state";
|
|
20
|
+
export * from "./world/tick";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class MessageLink {
|
|
2
|
+
constructor (
|
|
3
|
+
public index: number,
|
|
4
|
+
public sender: string,
|
|
5
|
+
public session: string
|
|
6
|
+
) { }
|
|
7
|
+
|
|
8
|
+
public static root(sender: string, session: string) {
|
|
9
|
+
return new MessageLink(0, sender, session);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public static unsinged(sender: string) { return this.root(sender, "null"); }
|
|
13
|
+
|
|
14
|
+
public isDescendantOf(link: MessageLink) {
|
|
15
|
+
return link.index > this.index && this.sender === link.sender && this.session === link.session;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class SignatureCache {
|
|
2
|
+
private entries: Buffer[];
|
|
3
|
+
|
|
4
|
+
constructor(public capacity: number) {
|
|
5
|
+
this.entries = Array.from({ length: this.capacity });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public static default() { return new SignatureCache(128); }
|
|
9
|
+
|
|
10
|
+
public get(index: number) { return this.entries[index]; }
|
|
11
|
+
|
|
12
|
+
public unpack = (messages: { message_id: number, signature?: number[] | undefined }[]) =>
|
|
13
|
+
messages.map(({ message_id: id, signature }) => signature ? Buffer.from(signature) : this.get(id)!);
|
|
14
|
+
|
|
15
|
+
public push(input: Buffer[]) {
|
|
16
|
+
const queue = input.slice();
|
|
17
|
+
const set = new Set(queue.map(v => v.toString("hex")));
|
|
18
|
+
for (let i = 0; i < this.entries.length && queue.length > 0; i++) {
|
|
19
|
+
const entry = !!this.entries[i] && Buffer.from(this.entries[i]!);
|
|
20
|
+
this.entries[i] = queue.pop()!;
|
|
21
|
+
if (entry && !set.has(entry.toString("hex")))
|
|
22
|
+
queue.unshift(entry);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Vec3 } from "../
|
|
1
|
+
import { Vec3 } from "../physics/direction";
|
|
2
2
|
import { CONTINUATION_FLAG, CONTINUE_BIT, MAX_QUANTIZED_VALUE, SCALE_BITS, SEGMENT_BITS } from "./static";
|
|
3
3
|
import { StringSizeExceedLimit, UnexpectedValue } from "../base/error";
|
|
4
4
|
import { Tag } from "./static";
|
|
5
5
|
import { unzipSync } from "zlib";
|
|
6
6
|
import { minBigInt } from "../base/math";
|
|
7
|
+
import { inspect } from "util";
|
|
7
8
|
|
|
8
9
|
export function getTextFromTextComponent(component: any): string {
|
|
9
10
|
if (component === null || component === undefined) return "null";
|
|
@@ -23,7 +24,7 @@ export function getTextFromTextComponent(component: any): string {
|
|
|
23
24
|
} else if ("keybind" in component)
|
|
24
25
|
return component["keybind"];
|
|
25
26
|
else
|
|
26
|
-
throw new UnexpectedValue("
|
|
27
|
+
throw new UnexpectedValue("value of component", "text component object", inspect(component, undefined, null));
|
|
27
28
|
}
|
|
28
29
|
default:
|
|
29
30
|
throw new UnexpectedValue("type of component", "string or object", typeof component);
|
|
@@ -396,6 +397,27 @@ export class BinaryDecoder {
|
|
|
396
397
|
return readX(this);
|
|
397
398
|
}
|
|
398
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Represents a set of IDs in a certain registry (implied by context), either directly (enumerated IDs) or indirectly (tag name).
|
|
402
|
+
* | Field Name | Field Type | Meaning |
|
|
403
|
+
* |------------|------------|---------|
|
|
404
|
+
* | Type | VarInt | Value used to determine the data that follows. It can be either: 0 - Represents a named set of IDs defined by a tag. Anything else - Represents an ad-hoc set of IDs enumerated inline. |
|
|
405
|
+
* | Tag Name | Optional Identifier | The registry tag defining the ID set. Only present if Type is 0. |
|
|
406
|
+
* | IDs | Optional Array of VarInt | An array of registry IDs. Only present if Type is not 0. The size of the array is equal to Type - 1. |
|
|
407
|
+
*/
|
|
408
|
+
public readIdSet() {
|
|
409
|
+
const type = this.readVarInt();
|
|
410
|
+
let tagName: string | null = null,
|
|
411
|
+
ids: number[] | null = null;
|
|
412
|
+
if (type === 0) tagName = this.readString();
|
|
413
|
+
else ids = this.readArray(type - 1, decoder => decoder.readVarInt());
|
|
414
|
+
return {
|
|
415
|
+
type,
|
|
416
|
+
tagName,
|
|
417
|
+
ids
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
399
421
|
/**
|
|
400
422
|
* Read Chat Type Decoration
|
|
401
423
|
*
|
|
@@ -609,7 +631,6 @@ export class SNBTDecoder {
|
|
|
609
631
|
outer:
|
|
610
632
|
while (true) {
|
|
611
633
|
ch = this.source[this.offset]!;
|
|
612
|
-
console.dir({ ch, type });
|
|
613
634
|
|
|
614
635
|
switch (ch) {
|
|
615
636
|
case "[":
|