@vaitosoi/minejs 0.2.1 → 0.3.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/assets/minecraft/26.2/packets.json +4741 -0
- package/dist/base/bitset.d.ts +9 -0
- package/dist/base/bitset.d.ts.map +1 -0
- package/dist/base/bitset.js +46 -0
- package/dist/base/bitset.js.map +1 -0
- package/dist/base/error.d.ts +105 -0
- package/dist/base/error.d.ts.map +1 -0
- package/dist/base/error.js +194 -0
- package/dist/base/error.js.map +1 -0
- package/dist/base/event.d.ts +7 -0
- package/dist/base/event.d.ts.map +1 -0
- package/dist/base/event.js +3 -0
- package/dist/base/event.js.map +1 -0
- package/dist/base/math.d.ts +25 -0
- package/dist/base/math.d.ts.map +1 -0
- package/dist/base/math.js +69 -0
- package/dist/base/math.js.map +1 -0
- package/dist/base/typing.d.ts +9 -0
- package/dist/base/typing.d.ts.map +1 -0
- package/dist/base/typing.js +3 -0
- package/dist/base/typing.js.map +1 -0
- package/dist/client/auth.d.ts +39 -0
- package/dist/client/auth.d.ts.map +1 -0
- package/dist/client/auth.js +307 -0
- package/dist/client/auth.js.map +1 -0
- package/dist/client/client.d.ts +73 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +136 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/static.d.ts +28 -0
- package/dist/client/static.d.ts.map +1 -0
- package/dist/client/static.js +43 -0
- package/dist/client/static.js.map +1 -0
- package/dist/client/tcp.d.ts +84 -0
- package/dist/client/tcp.d.ts.map +1 -0
- package/dist/client/tcp.js +173 -0
- package/dist/client/tcp.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -0
- package/dist/packet/decoder.d.ts +293 -0
- package/dist/packet/decoder.d.ts.map +1 -0
- package/dist/packet/decoder.js +668 -0
- package/dist/packet/decoder.js.map +1 -0
- package/dist/packet/dispatcher.d.ts +46 -0
- package/dist/packet/dispatcher.d.ts.map +1 -0
- package/dist/packet/dispatcher.js +626 -0
- package/dist/packet/dispatcher.js.map +1 -0
- package/dist/packet/encoder.d.ts +163 -0
- package/dist/packet/encoder.d.ts.map +1 -0
- package/dist/packet/encoder.js +441 -0
- package/dist/packet/encoder.js.map +1 -0
- package/dist/packet/static.d.ts +33 -0
- package/dist/packet/static.d.ts.map +1 -0
- package/dist/packet/static.js +42 -0
- package/dist/packet/static.js.map +1 -0
- package/dist/physics/aabb.d.ts +197 -0
- package/dist/physics/aabb.d.ts.map +1 -0
- package/dist/physics/aabb.js +576 -0
- package/dist/physics/aabb.js.map +1 -0
- package/dist/physics/direction.d.ts +153 -0
- package/dist/physics/direction.d.ts.map +1 -0
- package/dist/physics/direction.js +288 -0
- package/dist/physics/direction.js.map +1 -0
- package/dist/physics/player.d.ts +110 -0
- package/dist/physics/player.d.ts.map +1 -0
- package/dist/physics/player.js +558 -0
- 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 +214 -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 +289 -0
- package/dist/version/registry.js.map +1 -0
- package/dist/world/block.d.ts +86 -0
- package/dist/world/block.d.ts.map +1 -0
- package/dist/world/block.js +232 -0
- package/dist/world/block.js.map +1 -0
- package/dist/world/entity.d.ts +43 -0
- package/dist/world/entity.d.ts.map +1 -0
- package/dist/world/entity.js +97 -0
- package/dist/world/entity.js.map +1 -0
- package/dist/world/state.d.ts +151 -0
- package/dist/world/state.d.ts.map +1 -0
- package/dist/world/state.js +108 -0
- package/dist/world/state.js.map +1 -0
- package/dist/world/tick.d.ts +19 -0
- package/dist/world/tick.d.ts.map +1 -0
- package/dist/world/tick.js +49 -0
- package/dist/world/tick.js.map +1 -0
- package/package.json +7 -2
- package/src/base/error.ts +36 -0
- package/src/base/typing.ts +9 -1
- package/src/client/client.ts +99 -42
- package/src/client/tcp.ts +49 -954
- package/src/index.ts +12 -12
- package/src/{translator → packet}/decoder.ts +3 -3
- package/src/packet/dispatcher.ts +785 -0
- package/src/{translator → packet}/encoder.ts +20 -9
- package/src/{base → physics}/aabb.ts +5 -5
- package/src/{base → physics}/player.ts +41 -25
- package/src/version/codec.ts +227 -0
- package/src/version/registry.ts +333 -0
- package/src/{base → world}/block.ts +12 -11
- package/src/{base → world}/entity.ts +5 -5
- package/src/world/state.ts +232 -0
- package/test/adapter/index.ts +14 -0
- package/test/client/index.ts +1 -1
- package/test/json/index.ts +3 -0
- 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/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/base/registry.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
2
|
-
import { RegistryItemNotFound } from "./error";
|
|
3
|
-
import { Block, BlockState } from "./block";
|
|
4
|
-
|
|
5
|
-
export class EntityRegistry {
|
|
6
|
-
private static loaded: boolean = false;
|
|
7
|
-
public static readonly data: Record<string, { height: number, width: number, type: number }> = {};
|
|
8
|
-
public static readonly mapTypeToData: Record<number, string> = {};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Load entity registry from JSON file.
|
|
12
|
-
*
|
|
13
|
-
* Should be called once time
|
|
14
|
-
*/
|
|
15
|
-
public static async load() {
|
|
16
|
-
if (this.loaded) return;
|
|
17
|
-
this.loaded = true;
|
|
18
|
-
|
|
19
|
-
const file = await readFile(`${__dirname}/../../assets/minecraft/entities.json`, { encoding: "utf8" });
|
|
20
|
-
const json = JSON.parse(file);
|
|
21
|
-
for (const entity in json) {
|
|
22
|
-
this.data[entity] = json[entity];
|
|
23
|
-
this.mapTypeToData[json[entity]["id"]] = entity;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Get an entity registy item
|
|
29
|
-
*/
|
|
30
|
-
public static get(entity: string | number) {
|
|
31
|
-
if (typeof entity === "string") {
|
|
32
|
-
return this.data[entity];
|
|
33
|
-
} else {
|
|
34
|
-
const key = this.mapTypeToData[entity];
|
|
35
|
-
return this.data[key!];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export class BlockRegistry {
|
|
41
|
-
private static loaded: boolean = false;
|
|
42
|
-
/**
|
|
43
|
-
* block id to block
|
|
44
|
-
*/
|
|
45
|
-
public static readonly blocks: Record<string, Block> = {};
|
|
46
|
-
/**
|
|
47
|
-
* state id to block state
|
|
48
|
-
*/
|
|
49
|
-
public static readonly states: Record<string, BlockState> = {};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Load block registry from JSON file.
|
|
53
|
-
*
|
|
54
|
-
* Should be called once time
|
|
55
|
-
*/
|
|
56
|
-
public static async load() {
|
|
57
|
-
if (this.loaded) return;
|
|
58
|
-
this.loaded = true;
|
|
59
|
-
|
|
60
|
-
const file = await readFile(`${__dirname}/../../assets/minecraft/blocks.json`, { encoding: "utf8" });
|
|
61
|
-
const json = JSON.parse(file) as Record<string, any>;
|
|
62
|
-
for (const [type, blockRaw] of Object.entries(json)) {
|
|
63
|
-
const block = new Block(type, blockRaw['definition'], blockRaw['properties'], blockRaw['states']);
|
|
64
|
-
this.blocks[type] = block;
|
|
65
|
-
for (const state of block.states)
|
|
66
|
-
this.states[state.id] = state;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get a block registy item
|
|
72
|
-
*/
|
|
73
|
-
public static getBlock(type: string) {
|
|
74
|
-
if (!(type in this.blocks))
|
|
75
|
-
throw new RegistryItemNotFound(`block ${type}`);
|
|
76
|
-
return this.blocks[type]!;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get a block state registy item
|
|
81
|
-
*/
|
|
82
|
-
public static getState(id: string) {
|
|
83
|
-
if (!(id in this.states))
|
|
84
|
-
throw new RegistryItemNotFound(`block state ${id}`);
|
|
85
|
-
return this.states[id]!;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|