prismarine-proxy 1.0.0 → 1.1.2
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 +12 -0
- package/README.md +3 -3
- package/package.json +9 -9
- package/src/instant_connect_proxy.js +22 -22
- package/test/basic.test.js +2 -2
package/HISTORY.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
## History
|
|
2
2
|
|
|
3
|
+
### 1.1.2
|
|
4
|
+
|
|
5
|
+
- Update mcdata
|
|
6
|
+
|
|
7
|
+
### 1.1.1
|
|
8
|
+
|
|
9
|
+
- Fix bug with InstantConnectProxy to make connecting possible
|
|
10
|
+
|
|
11
|
+
### 1.1.0
|
|
12
|
+
|
|
13
|
+
- Make InstantConnectProxy use `minecraft-packets` to generate some packets
|
|
14
|
+
|
|
3
15
|
### 1.0.0
|
|
4
16
|
|
|
5
17
|
- Added InstantConnectProxy (@u9g)
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Provide features to build low and high level proxies, see https://github.com/Pri
|
|
|
13
13
|
Example of use case :
|
|
14
14
|
* client side proxies :
|
|
15
15
|
* make yourself a bot : do pathfinding like a bot, auto dig things, ...
|
|
16
|
-
* share your world view with a friend using prismarine-
|
|
16
|
+
* share your world view with a friend using prismarine-viewer
|
|
17
17
|
* server side proxies :
|
|
18
18
|
* act as a proxy with many vanilla client servers, with portals or commands to switch
|
|
19
19
|
* change things in server behavior : forbid going to some places, change the blocks, ...
|
|
@@ -36,7 +36,7 @@ const login = ['my@email.com', 'mypassword']
|
|
|
36
36
|
|
|
37
37
|
const proxy = new InstantConnectProxy({
|
|
38
38
|
loginHandler: (client) => { // client object has a username object, so you can store usernames with their respective logins
|
|
39
|
-
return { username: login[0], password:
|
|
39
|
+
return { username: login[0], password: login[1] } // the login the proxy will connect to the server with
|
|
40
40
|
},
|
|
41
41
|
serverOptions: { // options for the local server shown to the vanilla client
|
|
42
42
|
version: '1.8.9'
|
|
@@ -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.2",
|
|
4
4
|
"description": "Provide features to build proxies using Prismarine modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
8
|
-
"pretest": "npm run lint
|
|
9
|
-
"prepare": "npm install require-self && require-self",
|
|
7
|
+
"test": "mocha --reporter spec --exit",
|
|
8
|
+
"pretest": "npm run lint",
|
|
10
9
|
"lint": "standard",
|
|
11
10
|
"fix": "standard --fix"
|
|
12
11
|
},
|
|
@@ -25,13 +24,14 @@
|
|
|
25
24
|
},
|
|
26
25
|
"homepage": "https://github.com/PrismarineJS/prismarine-proxy#readme",
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
27
|
+
"mocha": "^9.1.3",
|
|
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": "^3.0.0",
|
|
34
|
+
"minecraft-packets": "^1.5.0",
|
|
35
|
+
"minecraft-protocol": "^1.13.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,6 +1,17 @@
|
|
|
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 verMap = {
|
|
7
|
+
'1.8.8': '1.8',
|
|
8
|
+
'1.8.9': '1.8'
|
|
9
|
+
}
|
|
10
|
+
function getPacket (ver, name) {
|
|
11
|
+
if (!packets[ver]) throw new Error(`Packets for version ${ver} aren't stored. This can be fixed by dumping them adding them to the verMap if similar packets are stored.`)
|
|
12
|
+
const packet = packets[ver]['from-server'][name][0].json
|
|
13
|
+
return packet
|
|
14
|
+
}
|
|
4
15
|
class InstantConnectProxy extends EventEmitter {
|
|
5
16
|
constructor (options) {
|
|
6
17
|
super()
|
|
@@ -16,15 +27,10 @@ class InstantConnectProxy extends EventEmitter {
|
|
|
16
27
|
|
|
17
28
|
onLogin (toClient) {
|
|
18
29
|
// until the proxyClient logs in, lets send a login packet
|
|
19
|
-
toClient.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
difficulty: 1,
|
|
24
|
-
maxPlayers: 20,
|
|
25
|
-
levelType: 'default',
|
|
26
|
-
reducedDebugInfo: false
|
|
27
|
-
})
|
|
30
|
+
const mcData = mcDataLoader(toClient.version)
|
|
31
|
+
const mcVersion = mcData.version.minecraftVersion
|
|
32
|
+
const ver = verMap[mcVersion] ?? mcVersion
|
|
33
|
+
toClient.write('login', { ...getPacket(ver, 'login'), entityId: toClient.id })
|
|
28
34
|
|
|
29
35
|
const toServer = createClient({
|
|
30
36
|
...this.options.clientOptions,
|
|
@@ -37,19 +43,13 @@ class InstantConnectProxy extends EventEmitter {
|
|
|
37
43
|
toServer.on('login', (data) => {
|
|
38
44
|
if (!this.clientIsOnline(toClient)) return
|
|
39
45
|
this.emit('start', toClient, toServer)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
toClient.write('respawn', {
|
|
48
|
-
dimension: data.dimension,
|
|
49
|
-
difficulty: data.difficulty,
|
|
50
|
-
gamemode: data.gameMode,
|
|
51
|
-
levelType: data.levelType
|
|
52
|
-
})
|
|
46
|
+
// https://github.com/VelocityPowered/Velocity/blob/aa210b3544556c46776976cddc45deb4ace9bb68/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java#L437
|
|
47
|
+
let dimension = data.dimension
|
|
48
|
+
if (mcData.isOlderThan('1.16')) {
|
|
49
|
+
dimension = data.dimension === 0 ? -1 : 0
|
|
50
|
+
}
|
|
51
|
+
toClient.write('respawn', { ...data, dimension })
|
|
52
|
+
toClient.write('respawn', data)
|
|
53
53
|
})
|
|
54
54
|
|
|
55
55
|
toClient.on('packet', (data, meta) => {
|