prismarine-proxy 1.1.0 → 1.1.3
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/.github/workflows/publish.yml +17 -10
- package/HISTORY.md +12 -0
- package/README.md +3 -3
- package/package.json +5 -5
- package/src/instant_connect_proxy.js +26 -22
- package/test/basic.test.js +2 -2
|
@@ -13,13 +13,20 @@ jobs:
|
|
|
13
13
|
- name: Set up Node.js
|
|
14
14
|
uses: actions/setup-node@master
|
|
15
15
|
with:
|
|
16
|
-
node-version:
|
|
17
|
-
-
|
|
18
|
-
uses:
|
|
19
|
-
with:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
node-version: 14.0.0
|
|
17
|
+
- id: publish
|
|
18
|
+
uses: JS-DevTools/npm-publish@v1
|
|
19
|
+
with:
|
|
20
|
+
token: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
21
|
+
- name: Create Release
|
|
22
|
+
if: steps.publish.outputs.type != 'none'
|
|
23
|
+
id: create_release
|
|
24
|
+
uses: actions/create-release@v1
|
|
25
|
+
env:
|
|
26
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
+
with:
|
|
28
|
+
tag_name: ${{ steps.publish.outputs.version }}
|
|
29
|
+
release_name: Release ${{ steps.publish.outputs.version }}
|
|
30
|
+
body: ${{ steps.publish.outputs.version }}
|
|
31
|
+
draft: false
|
|
32
|
+
prerelease: false
|
package/HISTORY.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
## History
|
|
2
2
|
|
|
3
|
+
### 1.1.3
|
|
4
|
+
|
|
5
|
+
- Use minecraft-data's login packet if one is not in minecraft-packets
|
|
6
|
+
|
|
7
|
+
### 1.1.2
|
|
8
|
+
|
|
9
|
+
- Update mcdata
|
|
10
|
+
|
|
11
|
+
### 1.1.1
|
|
12
|
+
|
|
13
|
+
- Fix bug with InstantConnectProxy to make connecting possible
|
|
14
|
+
|
|
3
15
|
### 1.1.0
|
|
4
16
|
|
|
5
17
|
- Make InstantConnectProxy use `minecraft-packets` to generate some packets
|
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](https://wiki.vg/Protocol
|
|
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,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prismarine-proxy",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Provide features to build proxies using Prismarine modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "mocha --reporter spec --exit",
|
|
8
8
|
"pretest": "npm run lint",
|
|
9
9
|
"lint": "standard",
|
|
10
10
|
"fix": "standard --fix"
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/PrismarineJS/prismarine-proxy#readme",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"
|
|
27
|
+
"mocha": "^10.0.0",
|
|
28
28
|
"prismarine-proxy": "file:.",
|
|
29
|
-
"standard": "^
|
|
29
|
+
"standard": "^17.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"debug": "^4.3.1",
|
|
33
|
-
"minecraft-data": "^
|
|
33
|
+
"minecraft-data": "^3.0.0",
|
|
34
34
|
"minecraft-packets": "^1.5.0",
|
|
35
35
|
"minecraft-protocol": "^1.13.0"
|
|
36
36
|
}
|
|
@@ -3,7 +3,20 @@ const { createServer, createClient } = require('minecraft-protocol')
|
|
|
3
3
|
const packets = require('minecraft-packets').pc
|
|
4
4
|
const mcDataLoader = require('minecraft-data')
|
|
5
5
|
const PLAY_STATE = 'play'
|
|
6
|
-
const
|
|
6
|
+
const verMap = {
|
|
7
|
+
'1.8.8': '1.8',
|
|
8
|
+
'1.8.9': '1.8'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getPacket (ver, name, mcData) {
|
|
12
|
+
let packet = packets[ver]?.['from-server']?.[name][0].json
|
|
13
|
+
if (name === 'login') {
|
|
14
|
+
packet = packet ?? mcData.loginPacket
|
|
15
|
+
}
|
|
16
|
+
if (!packet) 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.`)
|
|
17
|
+
return packet
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
class InstantConnectProxy extends EventEmitter {
|
|
8
21
|
constructor (options) {
|
|
9
22
|
super()
|
|
@@ -19,8 +32,10 @@ class InstantConnectProxy extends EventEmitter {
|
|
|
19
32
|
|
|
20
33
|
onLogin (toClient) {
|
|
21
34
|
// until the proxyClient logs in, lets send a login packet
|
|
22
|
-
const
|
|
23
|
-
|
|
35
|
+
const mcData = mcDataLoader(toClient.version)
|
|
36
|
+
const mcVersion = mcData.version.minecraftVersion
|
|
37
|
+
const ver = verMap[mcVersion] ?? mcVersion
|
|
38
|
+
toClient.write('login', { ...getPacket(ver, 'login', mcData), entityId: toClient.id })
|
|
24
39
|
|
|
25
40
|
const toServer = createClient({
|
|
26
41
|
...this.options.clientOptions,
|
|
@@ -33,25 +48,13 @@ class InstantConnectProxy extends EventEmitter {
|
|
|
33
48
|
toServer.on('login', (data) => {
|
|
34
49
|
if (!this.clientIsOnline(toClient)) return
|
|
35
50
|
this.emit('start', toClient, toServer)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
levelType: data.levelType
|
|
44
|
-
}
|
|
45
|
-
})
|
|
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
|
-
}
|
|
54
|
-
})
|
|
51
|
+
// https://github.com/VelocityPowered/Velocity/blob/aa210b3544556c46776976cddc45deb4ace9bb68/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java#L437
|
|
52
|
+
let dimension = data.dimension
|
|
53
|
+
if (mcData.isOlderThan('1.16')) {
|
|
54
|
+
dimension = data.dimension === 0 ? -1 : 0
|
|
55
|
+
}
|
|
56
|
+
toClient.write('respawn', { ...data, dimension })
|
|
57
|
+
toClient.write('respawn', data)
|
|
55
58
|
})
|
|
56
59
|
|
|
57
60
|
toClient.on('packet', (data, meta) => {
|
|
@@ -74,6 +77,7 @@ class InstantConnectProxy extends EventEmitter {
|
|
|
74
77
|
this.emit('incoming', data, meta, toClient, toServer)
|
|
75
78
|
}
|
|
76
79
|
})
|
|
80
|
+
|
|
77
81
|
toClient.once('end', () => {
|
|
78
82
|
this.emit('end', toServer.username)
|
|
79
83
|
this.endClient(toClient)
|