mineflayer 4.15.0 → 4.17.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/README.md CHANGED
@@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
17
17
 
18
18
  ## Features
19
19
 
20
- * Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20.
20
+ * Supports Minecraft 1.8 to 1.20.1 (1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20)
21
21
  * Entity knowledge and tracking.
22
22
  * Block knowledge. You can query the world around you. Milliseconds to find any block.
23
23
  * Physics and movement - handle all bounding boxes
package/docs/README.md CHANGED
@@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
17
17
 
18
18
  ## Features
19
19
 
20
- * Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20.
20
+ * Supports Minecraft 1.8 to 1.20.1 (1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20)
21
21
  * Entity knowledge and tracking.
22
22
  * Block knowledge. You can query the world around you. Milliseconds to find any block.
23
23
  * Physics and movement - handle all bounding boxes
package/docs/history.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 4.17.0
2
+ * [Exclude browser from node version check (#3268)](https://github.com/PrismarineJS/mineflayer/commit/c466d327227796865c53bfd24e66668911be4af5) (thanks @rom1504)
3
+ * [Fix for a possible error in lib/plugins/entities.js file (#3254)](https://github.com/PrismarineJS/mineflayer/commit/15cfeb4fa59edfcddf7a0b70a966294b24d798ed) (thanks @Mykola1453)
4
+ * [Make explicit supported versions in readme (#3264)](https://github.com/PrismarineJS/mineflayer/commit/931a4187965aef686c6188b944de84455c65b827) (thanks @rom1504)
5
+
6
+ ## 4.16.0
7
+ * [Fix version check (#3259)](https://github.com/PrismarineJS/mineflayer/commit/88d361f9209cdc2bc4620b32118fb2245f6dcdf9) (thanks @extremeheat)
8
+
1
9
  ## 4.15.0
2
10
  * [Fix several bugs in villager trading (#3230)](https://github.com/PrismarineJS/mineflayer/commit/1caa2c216b3a10a2bccd7b78a22f3809cb359fe3) (thanks @evan-goode)
3
11
  * [Fix `bot.heldItem` and `bot.entity.equipment` (#3225)](https://github.com/PrismarineJS/mineflayer/commit/9865ab72f7438fff9d74f2fe19a138da870c41aa) (thanks @szdytom)
package/index.d.ts CHANGED
@@ -867,7 +867,8 @@ export class Particle {
867
867
  );
868
868
  }
869
869
 
870
- export let supportedVersions: string[]
871
870
  export let testedVersions: string[]
871
+ export let latestSupportedVersion: string
872
+ export let oldestSupportedVersion: string
872
873
 
873
874
  export function supportFeature (feature: string, version: string): boolean
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- if (typeof process !== 'undefined' && parseInt(process.versions.node.split('.')[0]) < 18) {
1
+ if (typeof process !== 'undefined' && !process.browser && process.platform !== 'browser' && parseInt(process.versions.node.split('.')[0]) < 18) {
2
2
  console.error('Your node version is currently', process.versions.node)
3
3
  console.error('Please update it to a version >= 18.x.x from https://nodejs.org/')
4
4
  process.exit(1)
package/lib/loader.js CHANGED
@@ -45,8 +45,8 @@ const plugins = {
45
45
  particle: require('./plugins/particle')
46
46
  }
47
47
 
48
- const supportedVersions = require('./version').supportedVersions
49
- const testedVersions = require('./version').testedVersions
48
+ const minecraftData = require('minecraft-data')
49
+ const { testedVersions, latestSupportedVersion, oldestSupportedVersion } = require('./version')
50
50
 
51
51
  module.exports = {
52
52
  createBot,
@@ -55,9 +55,10 @@ module.exports = {
55
55
  ScoreBoard: require('./scoreboard'),
56
56
  BossBar: require('./bossbar'),
57
57
  Particle: require('./particle'),
58
- supportedVersions,
58
+ latestSupportedVersion,
59
+ oldestSupportedVersion,
59
60
  testedVersions,
60
- supportFeature: (feature, version) => require('prismarine-registry')(version).supportFeature(feature)
61
+ supportFeature: (feature, version) => minecraftData(version).supportFeature(feature)
61
62
  }
62
63
 
63
64
  function createBot (options = {}) {
@@ -107,22 +108,21 @@ function createBot (options = {}) {
107
108
  if (!bot._client.wait_connect) next()
108
109
  else bot._client.once('connect_allowed', next)
109
110
  function next () {
110
- bot.registry = require('prismarine-registry')(bot._client.version)
111
- const version = bot.registry.version
112
- if (supportedVersions.indexOf(version.majorVersion) === -1) {
113
- throw new Error(`Version ${version.minecraftVersion} is not supported.`)
114
- }
111
+ const serverPingVersion = bot._client.version
112
+ bot.registry = require('prismarine-registry')(serverPingVersion)
113
+ if (!bot.registry?.version) throw new Error(`Server version '${serverPingVersion}' is not supported, no data for version`)
115
114
 
116
- const latestTestedVersion = testedVersions[testedVersions.length - 1]
117
- const latestProtocolVersion = require('prismarine-registry')(latestTestedVersion).protocolVersion
118
- if (version.protocolVersion > latestProtocolVersion) {
119
- throw new Error(`Version ${version.minecraftVersion} is not supported. Latest supported version is ${latestTestedVersion}.`)
115
+ const versionData = bot.registry.version
116
+ if (versionData['>'](latestSupportedVersion)) {
117
+ throw new Error(`Server version '${serverPingVersion}' is not supported. Latest supported version is '${latestSupportedVersion}'.`)
118
+ } else if (versionData['<'](oldestSupportedVersion)) {
119
+ throw new Error(`Server version '${serverPingVersion}' is not supported. Oldest supported version is '${oldestSupportedVersion}'.`)
120
120
  }
121
121
 
122
- bot.protocolVersion = version.version
123
- bot.majorVersion = version.majorVersion
124
- bot.version = version.minecraftVersion
125
- options.version = version.minecraftVersion
122
+ bot.protocolVersion = versionData.version
123
+ bot.majorVersion = versionData.majorVersion
124
+ bot.version = versionData.minecraftVersion
125
+ options.version = versionData.minecraftVersion
126
126
  bot.supportFeature = bot.registry.supportFeature
127
127
  setTimeout(() => bot.emit('inject_allowed'), 0)
128
128
  }
@@ -176,6 +176,7 @@ function inject (bot) {
176
176
  entityData = entitiesArray.find(entity => entity.internalId === type)
177
177
  }
178
178
  if (entityData) {
179
+ entity.type = entityData.type || 'object'
179
180
  entity.displayName = entityData.displayName
180
181
  entity.entityType = entityData.id
181
182
  entity.name = entityData.name
@@ -196,8 +197,6 @@ function inject (bot) {
196
197
  bot._client.on('spawn_entity', (packet) => {
197
198
  const entity = fetchEntity(packet.entityId)
198
199
  const entityData = bot.registry.entities[packet.type]
199
-
200
- entity.type = entityData.type || 'object'
201
200
  setEntityData(entity, packet.type, entityData)
202
201
 
203
202
  if (bot.supportFeature('fixedPointPosition')) {
package/lib/version.js CHANGED
@@ -1,4 +1,6 @@
1
+ const testedVersions = ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1']
1
2
  module.exports = {
2
- supportedVersions: ['1.8', '1.9', '1.10', '1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19', '1.20'],
3
- testedVersions: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1']
3
+ testedVersions,
4
+ latestSupportedVersion: testedVersions[testedVersions.length - 1],
5
+ oldestSupportedVersion: testedVersions[0]
4
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mineflayer",
3
- "version": "4.15.0",
3
+ "version": "4.17.0",
4
4
  "description": "create minecraft bots with a stable, high level API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",