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 CHANGED
@@ -1,5 +1,9 @@
1
1
  ## History
2
2
 
3
+ ### 1.1.0
4
+
5
+ - Make InstantConnectProxy use `minecraft-packets` to generate some packets
6
+
3
7
  ### 1.0.0
4
8
 
5
9
  - Added InstantConnectProxy (@u9g)
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.0.0",
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 && require-self",
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
- "standard": "^16.0.1",
30
- "prismarine-proxy": "file:."
28
+ "prismarine-proxy": "file:.",
29
+ "standard": "^16.0.1"
31
30
  },
32
31
  "dependencies": {
33
32
  "debug": "^4.3.1",
34
- "minecraft-protocol": "^1.13.0",
35
- "require-self": "^0.2.3"
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.write('login', {
20
- entityId: toClient.id,
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
- dimension,
43
- difficulty: data.difficulty,
44
- gamemode: data.gameMode,
45
- levelType: data.levelType
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('respawn', {
48
- dimension: data.dimension,
49
- difficulty: data.difficulty,
50
- gamemode: data.gameMode,
51
- levelType: data.levelType
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