prismarine-proxy 1.0.0 → 1.1.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/HISTORY.md +4 -0
- package/README.md +1 -1
- package/package.json +7 -7
- package/src/instant_connect_proxy.js +20 -18
package/HISTORY.md
CHANGED
package/README.md
CHANGED
|
@@ -58,4 +58,4 @@ proxy.on('outgoing', (data, meta, toClient, toServer) => { // packets outgoing f
|
|
|
58
58
|
})
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
The name of the particles can be found [here](https://minecraft-data.prismarine.js.org/) , make sure to select the version you are playing on at the top then click protocol, more info about packets can be found [here](wiki.vg/Protocol) , make sure to select the version you are working with
|
|
61
|
+
The name of the particles can be found [here](https://minecraft-data.prismarine.js.org/) , make sure to select the version you are playing on at the top then click protocol, more info about packets can be found [here](https://wiki.vg/Protocol/) , make sure to select the version you are working with
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prismarine-proxy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Provide features to build proxies using Prismarine modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest --verbose",
|
|
8
|
-
"pretest": "npm run lint
|
|
9
|
-
"prepare": "npm install require-self && require-self",
|
|
8
|
+
"pretest": "npm run lint",
|
|
10
9
|
"lint": "standard",
|
|
11
10
|
"fix": "standard --fix"
|
|
12
11
|
},
|
|
@@ -26,12 +25,13 @@
|
|
|
26
25
|
"homepage": "https://github.com/PrismarineJS/prismarine-proxy#readme",
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"jest": "^27.0.4",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
28
|
+
"prismarine-proxy": "file:.",
|
|
29
|
+
"standard": "^16.0.1"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
32
|
"debug": "^4.3.1",
|
|
34
|
-
"minecraft-
|
|
35
|
-
"
|
|
33
|
+
"minecraft-data": "^2.94.0",
|
|
34
|
+
"minecraft-packets": "^1.5.0",
|
|
35
|
+
"minecraft-protocol": "^1.13.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const EventEmitter = require('events')
|
|
2
2
|
const { createServer, createClient } = require('minecraft-protocol')
|
|
3
|
+
const packets = require('minecraft-packets').pc
|
|
4
|
+
const mcDataLoader = require('minecraft-data')
|
|
3
5
|
const PLAY_STATE = 'play'
|
|
6
|
+
const getPacket = (ver, name) => packets[ver]['from-server'][name][0].json
|
|
4
7
|
class InstantConnectProxy extends EventEmitter {
|
|
5
8
|
constructor (options) {
|
|
6
9
|
super()
|
|
@@ -16,15 +19,8 @@ class InstantConnectProxy extends EventEmitter {
|
|
|
16
19
|
|
|
17
20
|
onLogin (toClient) {
|
|
18
21
|
// until the proxyClient logs in, lets send a login packet
|
|
19
|
-
toClient.
|
|
20
|
-
|
|
21
|
-
gameMode: 0,
|
|
22
|
-
dimension: 0,
|
|
23
|
-
difficulty: 1,
|
|
24
|
-
maxPlayers: 20,
|
|
25
|
-
levelType: 'default',
|
|
26
|
-
reducedDebugInfo: false
|
|
27
|
-
})
|
|
22
|
+
const ver = mcDataLoader(toClient.version).version.minecraftVersion
|
|
23
|
+
toClient.write('login', { ...getPacket(ver, 'login'), entityId: toClient.id })
|
|
28
24
|
|
|
29
25
|
const toServer = createClient({
|
|
30
26
|
...this.options.clientOptions,
|
|
@@ -39,16 +35,22 @@ class InstantConnectProxy extends EventEmitter {
|
|
|
39
35
|
this.emit('start', toClient, toServer)
|
|
40
36
|
const dimension = data.dimension === 0 ? -1 : 0
|
|
41
37
|
toClient.write('respawn', {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
...getPacket(ver, 'respawn'),
|
|
39
|
+
...{
|
|
40
|
+
dimension,
|
|
41
|
+
difficulty: data.difficulty,
|
|
42
|
+
gamemode: data.gameMode,
|
|
43
|
+
levelType: data.levelType
|
|
44
|
+
}
|
|
46
45
|
})
|
|
47
|
-
toClient.write('
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
toClient.write('login', {
|
|
47
|
+
...getPacket(ver, 'respawn'),
|
|
48
|
+
...{
|
|
49
|
+
dimension: data.dimension,
|
|
50
|
+
difficulty: data.difficulty,
|
|
51
|
+
gamemode: data.gameMode,
|
|
52
|
+
levelType: data.levelType
|
|
53
|
+
}
|
|
52
54
|
})
|
|
53
55
|
})
|
|
54
56
|
|