@vaitosoi/minejs 0.5.1 → 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 +25 -9
- package/assets/minecraft/26.2/components.json +113 -0
- package/assets/minecraft/26.2/packets.json +8 -28
- package/assets/minecraft/26.3/packets.json +4957 -0
- package/assets/minecraft/versionMapping.json +16 -0
- package/dist/binary/decoder.d.ts +35 -0
- package/dist/binary/decoder.d.ts.map +1 -1
- package/dist/binary/decoder.js +665 -2
- package/dist/binary/decoder.js.map +1 -1
- package/dist/binary/encoder.d.ts +3 -3
- 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 +178 -22
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +132 -13
- package/dist/client/client.js.map +1 -1
- package/dist/net/tcp.d.ts +6 -9
- package/dist/net/tcp.d.ts.map +1 -1
- package/dist/net/tcp.js +16 -19
- package/dist/net/tcp.js.map +1 -1
- package/dist/packet/listener.d.ts +6 -1
- package/dist/packet/listener.d.ts.map +1 -1
- package/dist/packet/listener.js +220 -60
- package/dist/packet/listener.js.map +1 -1
- package/dist/packet/sender.d.ts +4 -1
- package/dist/packet/sender.d.ts.map +1 -1
- package/dist/packet/sender.js +30 -4
- package/dist/packet/sender.js.map +1 -1
- package/dist/physics/aabb.d.ts.map +1 -1
- package/dist/physics/aabb.js +17 -9
- 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/physics/player.js +1 -5
- package/dist/physics/player.js.map +1 -1
- package/dist/version/codec.d.ts.map +1 -1
- package/dist/version/codec.js +63 -14
- package/dist/version/codec.js.map +1 -1
- package/dist/version/registry.d.ts +26 -5
- package/dist/version/registry.d.ts.map +1 -1
- package/dist/version/registry.js +78 -18
- package/dist/version/registry.js.map +1 -1
- package/dist/world/block.d.ts +54 -10
- package/dist/world/block.d.ts.map +1 -1
- package/dist/world/block.js +78 -32
- package/dist/world/block.js.map +1 -1
- package/dist/world/container.d.ts +106 -0
- package/dist/world/container.d.ts.map +1 -0
- package/dist/world/container.js +240 -0
- package/dist/world/container.js.map +1 -0
- 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 +11 -5
- package/dist/world/state.d.ts.map +1 -1
- package/dist/world/state.js +11 -0
- package/dist/world/state.js.map +1 -1
- package/package.json +2 -2
- package/src/binary/decoder.ts +691 -2
- package/src/binary/encoder.ts +8 -9
- package/src/client/client.ts +234 -34
- package/src/net/tcp.ts +27 -22
- package/src/packet/listener.ts +275 -76
- package/src/packet/sender.ts +42 -7
- package/src/physics/aabb.ts +18 -9
- package/src/physics/direction.ts +2 -2
- package/src/physics/player.ts +5 -5
- package/src/version/codec.ts +56 -14
- package/src/version/registry.ts +92 -18
- package/src/world/block.ts +83 -39
- package/src/world/container.ts +180 -0
- package/src/world/entity.ts +3 -0
- package/src/world/state.ts +21 -6
- package/test/client/index.ts +56 -21
- package/test/client/registry.json +1735 -0
package/README.md
CHANGED
|
@@ -12,6 +12,11 @@ This package is highly unstable for now, please report if there is any bug, glit
|
|
|
12
12
|
|
|
13
13
|
Also, since there is some problem with authenticating and appId approval, I haven't completed the join "online server" part yet. [See more here](#iv-about-joining-online-server)
|
|
14
14
|
|
|
15
|
+
About support version:
|
|
16
|
+
+ `26.2`: supported well since the Wiki page of it is considered as the stable.
|
|
17
|
+
+ `26.3`: there are some issues with packet decoding
|
|
18
|
+
+ `26.4`: not even existed 😭
|
|
19
|
+
|
|
15
20
|
## II. Usage
|
|
16
21
|
|
|
17
22
|
Install MineJS using your favorite package manager:
|
|
@@ -26,13 +31,14 @@ Then write a simple code like this:
|
|
|
26
31
|
// index.ts
|
|
27
32
|
import { Input, Client } from "@vaitosoi/minejs";
|
|
28
33
|
|
|
34
|
+
// Init a client
|
|
29
35
|
const client = new Client({
|
|
30
|
-
playerName: "bot",
|
|
31
|
-
host: "localhost",
|
|
32
|
-
port: 25565,
|
|
33
|
-
version: "26.2",
|
|
34
|
-
loadRegistry: false,
|
|
35
|
-
// auth: {
|
|
36
|
+
playerName: "bot", // Put your name here
|
|
37
|
+
host: "localhost", // Put the server address
|
|
38
|
+
port: 25565, // 25565 is the default port, change to your server's port if needed
|
|
39
|
+
version: "26.2", // The client version
|
|
40
|
+
loadRegistry: false, //
|
|
41
|
+
// auth: { // This things is not working yet
|
|
36
42
|
// client_id: "d86254d8-edf7-4640-90eb-643c99af188e",
|
|
37
43
|
// method: "loopback",
|
|
38
44
|
// openBrowser: true,
|
|
@@ -41,7 +47,11 @@ const client = new Client({
|
|
|
41
47
|
// shouldVerifyMessageOrder: true,
|
|
42
48
|
// shouldVerifyMessageSignature: true
|
|
43
49
|
});
|
|
50
|
+
|
|
51
|
+
// After initialization, start your client
|
|
44
52
|
client.connect();
|
|
53
|
+
|
|
54
|
+
// Listen to events
|
|
45
55
|
client.on("disconnect", (...args) => console.dir({ name: "disconnect", args }, { depth: null }));
|
|
46
56
|
client.on("disconnectRaw", (...args) => console.dir({ name: "disconnectRaw", args }, { depth: null }));
|
|
47
57
|
// client.on("loadChunk", (...args) => console.dir({ name: "loadChunk", args }, { depth: null }));
|
|
@@ -55,10 +65,13 @@ client.on("systemMessage", (...args) => console.dir({ name: "systemMessage", arg
|
|
|
55
65
|
client.on("systemMessageRaw", (...args) => console.dir({ name: "systemMessageRaw", args }, { depth: null }));
|
|
56
66
|
client.on("actionBar", (...args) => console.dir({ name: "actionBar", args }, { depth: null }));
|
|
57
67
|
client.on("actionBarRaw", (...args) => console.dir({ name: "actionBarRaw", args }, { depth: null }));
|
|
68
|
+
|
|
69
|
+
// Interact with the world
|
|
58
70
|
client.on("message", (message) => {
|
|
59
71
|
if (!message.content.startsWith("_")) return;
|
|
60
72
|
const args = message.content.slice(1).split(" ");
|
|
61
73
|
switch (args[0]) {
|
|
74
|
+
// Moving around
|
|
62
75
|
case "w": client.hold(Input.Forward); break;
|
|
63
76
|
case "sw": client.release(Input.Forward); break;
|
|
64
77
|
case "ws":
|
|
@@ -77,13 +90,15 @@ client.on("message", (message) => {
|
|
|
77
90
|
case "srun": client.release(Input.Sprint); break;
|
|
78
91
|
case "stop": client.stopMoving(); break;
|
|
79
92
|
|
|
93
|
+
// Looking around
|
|
80
94
|
case "at": {
|
|
81
95
|
const [, x, y, z] = args.map(val => parseInt(val)) as [any, number, number, number];
|
|
82
|
-
const state = client.
|
|
96
|
+
const state = client.getBlock(x, y, z);
|
|
83
97
|
console.log(state);
|
|
84
98
|
break;
|
|
85
99
|
}
|
|
86
100
|
|
|
101
|
+
// Saying words
|
|
87
102
|
case "e":
|
|
88
103
|
case "echo":
|
|
89
104
|
case "say": {
|
|
@@ -92,6 +107,7 @@ client.on("message", (message) => {
|
|
|
92
107
|
break;
|
|
93
108
|
}
|
|
94
109
|
|
|
110
|
+
// And exit
|
|
95
111
|
case "disconnect":
|
|
96
112
|
case "exit":
|
|
97
113
|
client.disconnect();
|
|
@@ -102,7 +118,7 @@ client.on("message", (message) => {
|
|
|
102
118
|
|
|
103
119
|
And run it:
|
|
104
120
|
|
|
105
|
-
```
|
|
121
|
+
```bash
|
|
106
122
|
npm tsx index.ts
|
|
107
123
|
```
|
|
108
124
|
|
|
@@ -144,7 +160,7 @@ pause-when-empty-seconds=60
|
|
|
144
160
|
|
|
145
161
|
or
|
|
146
162
|
|
|
147
|
-
2. Try some crack launcher to join that
|
|
163
|
+
2. Try some crack launcher to join that server
|
|
148
164
|
|
|
149
165
|
### 4. Note:
|
|
150
166
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"minecraft:additional_trade_cost": 41,
|
|
3
|
+
"minecraft:attack_range": 30,
|
|
4
|
+
"minecraft:attribute_modifiers": 16,
|
|
5
|
+
"minecraft:axolotl/variant": 105,
|
|
6
|
+
"minecraft:banner_patterns": 72,
|
|
7
|
+
"minecraft:base_color": 73,
|
|
8
|
+
"minecraft:bees": 77,
|
|
9
|
+
"minecraft:block_entity_data": 60,
|
|
10
|
+
"minecraft:block_state": 76,
|
|
11
|
+
"minecraft:blocks_attacks": 37,
|
|
12
|
+
"minecraft:break_sound": 81,
|
|
13
|
+
"minecraft:bucket_entity_data": 59,
|
|
14
|
+
"minecraft:bundle_contents": 50,
|
|
15
|
+
"minecraft:can_break": 15,
|
|
16
|
+
"minecraft:can_place_on": 14,
|
|
17
|
+
"minecraft:cat/collar": 108,
|
|
18
|
+
"minecraft:cat/sound_variant": 107,
|
|
19
|
+
"minecraft:cat/variant": 106,
|
|
20
|
+
"minecraft:charged_projectiles": 49,
|
|
21
|
+
"minecraft:chicken/sound_variant": 99,
|
|
22
|
+
"minecraft:chicken/variant": 98,
|
|
23
|
+
"minecraft:consumable": 24,
|
|
24
|
+
"minecraft:container": 75,
|
|
25
|
+
"minecraft:container_loot": 80,
|
|
26
|
+
"minecraft:cow/sound_variant": 97,
|
|
27
|
+
"minecraft:cow/variant": 96,
|
|
28
|
+
"minecraft:creative_slot_lock": 20,
|
|
29
|
+
"minecraft:custom_data": 0,
|
|
30
|
+
"minecraft:custom_model_data": 17,
|
|
31
|
+
"minecraft:custom_name": 6,
|
|
32
|
+
"minecraft:damage": 3,
|
|
33
|
+
"minecraft:damage_resistant": 27,
|
|
34
|
+
"minecraft:damage_type": 8,
|
|
35
|
+
"minecraft:death_protection": 36,
|
|
36
|
+
"minecraft:debug_stick_state": 57,
|
|
37
|
+
"minecraft:dye": 43,
|
|
38
|
+
"minecraft:dyed_color": 44,
|
|
39
|
+
"minecraft:enchantable": 31,
|
|
40
|
+
"minecraft:enchantment_glint_override": 21,
|
|
41
|
+
"minecraft:enchantments": 13,
|
|
42
|
+
"minecraft:entity_data": 58,
|
|
43
|
+
"minecraft:equippable": 32,
|
|
44
|
+
"minecraft:firework_explosion": 68,
|
|
45
|
+
"minecraft:fireworks": 69,
|
|
46
|
+
"minecraft:food": 23,
|
|
47
|
+
"minecraft:fox/variant": 86,
|
|
48
|
+
"minecraft:frog/variant": 101,
|
|
49
|
+
"minecraft:glider": 34,
|
|
50
|
+
"minecraft:horse/variant": 102,
|
|
51
|
+
"minecraft:instrument": 61,
|
|
52
|
+
"minecraft:intangible_projectile": 22,
|
|
53
|
+
"minecraft:item_model": 10,
|
|
54
|
+
"minecraft:item_name": 9,
|
|
55
|
+
"minecraft:jukebox_playable": 64,
|
|
56
|
+
"minecraft:kinetic_weapon": 39,
|
|
57
|
+
"minecraft:llama/variant": 104,
|
|
58
|
+
"minecraft:lock": 79,
|
|
59
|
+
"minecraft:lodestone_tracker": 67,
|
|
60
|
+
"minecraft:lore": 11,
|
|
61
|
+
"minecraft:map_color": 45,
|
|
62
|
+
"minecraft:map_decorations": 47,
|
|
63
|
+
"minecraft:map_id": 46,
|
|
64
|
+
"minecraft:map_post_processing": 48,
|
|
65
|
+
"minecraft:max_damage": 2,
|
|
66
|
+
"minecraft:max_stack_size": 1,
|
|
67
|
+
"minecraft:minimum_attack_charge": 7,
|
|
68
|
+
"minecraft:mooshroom/variant": 92,
|
|
69
|
+
"minecraft:note_block_sound": 71,
|
|
70
|
+
"minecraft:ominous_bottle_amplifier": 63,
|
|
71
|
+
"minecraft:painting/variant": 103,
|
|
72
|
+
"minecraft:parrot/variant": 88,
|
|
73
|
+
"minecraft:piercing_weapon": 38,
|
|
74
|
+
"minecraft:pig/sound_variant": 95,
|
|
75
|
+
"minecraft:pig/variant": 94,
|
|
76
|
+
"minecraft:pot_decorations": 74,
|
|
77
|
+
"minecraft:potion_contents": 51,
|
|
78
|
+
"minecraft:potion_duration_scale": 52,
|
|
79
|
+
"minecraft:profile": 70,
|
|
80
|
+
"minecraft:provides_banner_patterns": 65,
|
|
81
|
+
"minecraft:provides_trim_material": 62,
|
|
82
|
+
"minecraft:rabbit/variant": 93,
|
|
83
|
+
"minecraft:rarity": 12,
|
|
84
|
+
"minecraft:recipes": 66,
|
|
85
|
+
"minecraft:repair_cost": 19,
|
|
86
|
+
"minecraft:repairable": 33,
|
|
87
|
+
"minecraft:salmon/size": 87,
|
|
88
|
+
"minecraft:sheep/color": 109,
|
|
89
|
+
"minecraft:shulker/color": 110,
|
|
90
|
+
"minecraft:stored_enchantments": 42,
|
|
91
|
+
"minecraft:sulfur_cube_content": 78,
|
|
92
|
+
"minecraft:suspicious_stew_effects": 53,
|
|
93
|
+
"minecraft:swing_animation": 40,
|
|
94
|
+
"minecraft:tool": 28,
|
|
95
|
+
"minecraft:tooltip_display": 18,
|
|
96
|
+
"minecraft:tooltip_style": 35,
|
|
97
|
+
"minecraft:trim": 56,
|
|
98
|
+
"minecraft:tropical_fish/base_color": 90,
|
|
99
|
+
"minecraft:tropical_fish/pattern": 89,
|
|
100
|
+
"minecraft:tropical_fish/pattern_color": 91,
|
|
101
|
+
"minecraft:unbreakable": 4,
|
|
102
|
+
"minecraft:use_cooldown": 26,
|
|
103
|
+
"minecraft:use_effects": 5,
|
|
104
|
+
"minecraft:use_remainder": 25,
|
|
105
|
+
"minecraft:villager/variant": 82,
|
|
106
|
+
"minecraft:weapon": 29,
|
|
107
|
+
"minecraft:wolf/collar": 85,
|
|
108
|
+
"minecraft:wolf/sound_variant": 84,
|
|
109
|
+
"minecraft:wolf/variant": 83,
|
|
110
|
+
"minecraft:writable_book_content": 54,
|
|
111
|
+
"minecraft:written_book_content": 55,
|
|
112
|
+
"minecraft:zombie_nautilus/variant": 100
|
|
113
|
+
}
|
|
@@ -958,13 +958,11 @@
|
|
|
958
958
|
"slot_data": {
|
|
959
959
|
"type": "prefixed_array",
|
|
960
960
|
"subType": {
|
|
961
|
-
"type": "
|
|
962
|
-
"comment": "Slot"
|
|
961
|
+
"type": "slot"
|
|
963
962
|
}
|
|
964
963
|
},
|
|
965
964
|
"carried_item": {
|
|
966
|
-
"type": "
|
|
967
|
-
"comment": "Slot"
|
|
965
|
+
"type": "slot"
|
|
968
966
|
}
|
|
969
967
|
}
|
|
970
968
|
},
|
|
@@ -997,8 +995,7 @@
|
|
|
997
995
|
"type": "short"
|
|
998
996
|
},
|
|
999
997
|
"slot_data": {
|
|
1000
|
-
"type": "
|
|
1001
|
-
"comment": "Slot"
|
|
998
|
+
"type": "slot"
|
|
1002
999
|
}
|
|
1003
1000
|
}
|
|
1004
1001
|
},
|
|
@@ -1651,12 +1648,6 @@
|
|
|
1651
1648
|
{
|
|
1652
1649
|
"type": "boolean"
|
|
1653
1650
|
}
|
|
1654
|
-
],
|
|
1655
|
-
[
|
|
1656
|
-
false,
|
|
1657
|
-
{
|
|
1658
|
-
"type": "null"
|
|
1659
|
-
}
|
|
1660
1651
|
]
|
|
1661
1652
|
],
|
|
1662
1653
|
"default": {
|
|
@@ -1672,12 +1663,6 @@
|
|
|
1672
1663
|
{
|
|
1673
1664
|
"type": "position"
|
|
1674
1665
|
}
|
|
1675
|
-
],
|
|
1676
|
-
[
|
|
1677
|
-
false,
|
|
1678
|
-
{
|
|
1679
|
-
"type": "null"
|
|
1680
|
-
}
|
|
1681
1666
|
]
|
|
1682
1667
|
],
|
|
1683
1668
|
"default": {
|
|
@@ -1774,8 +1759,7 @@
|
|
|
1774
1759
|
"comment": "Trade Item"
|
|
1775
1760
|
},
|
|
1776
1761
|
"output_item": {
|
|
1777
|
-
"type": "
|
|
1778
|
-
"comment": "Slot"
|
|
1762
|
+
"type": "slot"
|
|
1779
1763
|
},
|
|
1780
1764
|
"input_item_2": {
|
|
1781
1765
|
"type": "prefixed_optional",
|
|
@@ -2657,8 +2641,7 @@
|
|
|
2657
2641
|
"id": 96,
|
|
2658
2642
|
"structure": {
|
|
2659
2643
|
"carried_item": {
|
|
2660
|
-
"type": "
|
|
2661
|
-
"comment": "Slot"
|
|
2644
|
+
"type": "slot"
|
|
2662
2645
|
}
|
|
2663
2646
|
}
|
|
2664
2647
|
},
|
|
@@ -2749,8 +2732,7 @@
|
|
|
2749
2732
|
}
|
|
2750
2733
|
},
|
|
2751
2734
|
"item": {
|
|
2752
|
-
"type": "
|
|
2753
|
-
"comment": "Slot"
|
|
2735
|
+
"type": "slot"
|
|
2754
2736
|
}
|
|
2755
2737
|
}
|
|
2756
2738
|
}
|
|
@@ -2819,8 +2801,7 @@
|
|
|
2819
2801
|
"type": "var_int"
|
|
2820
2802
|
},
|
|
2821
2803
|
"slot_data": {
|
|
2822
|
-
"type": "
|
|
2823
|
-
"comment": "Slot"
|
|
2804
|
+
"type": "slot"
|
|
2824
2805
|
}
|
|
2825
2806
|
}
|
|
2826
2807
|
},
|
|
@@ -4426,8 +4407,7 @@
|
|
|
4426
4407
|
"type": "short"
|
|
4427
4408
|
},
|
|
4428
4409
|
"clicked_item": {
|
|
4429
|
-
"type": "
|
|
4430
|
-
"comment": "Slot"
|
|
4410
|
+
"type": "slot"
|
|
4431
4411
|
}
|
|
4432
4412
|
}
|
|
4433
4413
|
},
|