minecraft-data 2.115.1 → 2.115.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/.github/workflows/ci.yml +5 -0
- package/doc/api.md +4 -0
- package/doc/history.md +3 -0
- package/index.js +2 -1
- package/lib/supportsFeature.js +31 -0
- package/package.json +1 -1
package/.github/workflows/ci.yml
CHANGED
package/doc/api.md
CHANGED
|
@@ -337,6 +337,10 @@ Mapping from 1.12 block:metadata to 1.13 block names
|
|
|
337
337
|
|
|
338
338
|
examples 0:0 -> minecraft:air
|
|
339
339
|
|
|
340
|
+
### minecraft-data.supportFeature(featureName) : Boolean
|
|
341
|
+
|
|
342
|
+
This can be used to check is a specific feature is available in the current Minecraft version. This is usually only required for handling version-specific functionality.
|
|
343
|
+
|
|
340
344
|
## Schemas
|
|
341
345
|
|
|
342
346
|
### minecraft-data.schemas.biomes
|
package/doc/history.md
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const mcDataToNode = require('./lib/loader')
|
|
2
|
+
const supportFeature = require('./lib/supportsFeature')
|
|
2
3
|
const indexer = require('./lib/indexer.js')
|
|
3
4
|
const protocolVersions = {
|
|
4
5
|
pc: require('./minecraft-data/data/pc/common/protocolVersions.json'),
|
|
@@ -63,7 +64,7 @@ module.exports = function (mcVersion, preNetty) {
|
|
|
63
64
|
nmcData.isOlderThan = version => nmcData.version['<'](version)
|
|
64
65
|
nmcData.version = Object.assign(majorVersion, nmcData.version)
|
|
65
66
|
cache[majorVersion.type + '_' + majorVersion.majorVersion] = nmcData
|
|
66
|
-
|
|
67
|
+
nmcData.supportFeature = feature => supportFeature(feature, nmcData.version.minecraftVersion)
|
|
67
68
|
return nmcData
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const features = require('../minecraft-data/data/pc/common/features.json')
|
|
2
|
+
|
|
3
|
+
const versions = {
|
|
4
|
+
pc: require('../minecraft-data/data/pc/common/protocolVersions.json'),
|
|
5
|
+
bedrock: require('../minecraft-data/data/bedrock/common/protocolVersions.json')
|
|
6
|
+
}
|
|
7
|
+
const versionList = versions.pc
|
|
8
|
+
const versionToIndex = Object.fromEntries(versionList.map((version, i) => [version.minecraftVersion, versionList.length - i]))
|
|
9
|
+
const nameToFeature = Object.fromEntries(features.map(feature => [feature.name, feature]))
|
|
10
|
+
|
|
11
|
+
module.exports = (featureName, minecraftVersion) => {
|
|
12
|
+
const feature = nameToFeature[featureName]
|
|
13
|
+
if (feature === undefined) {
|
|
14
|
+
throw new Error(`Feature ${feature} doesn't exist`)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const currentVer = versionToIndex[minecraftVersion]
|
|
18
|
+
const minVer = versionToIndex[feature.versions[0]]
|
|
19
|
+
const maxVer = versionToIndex[feature.versions[1]]
|
|
20
|
+
if (currentVer === undefined) {
|
|
21
|
+
throw new Error(`Version ${minecraftVersion} doesn't exist`)
|
|
22
|
+
}
|
|
23
|
+
if (minVer === undefined) {
|
|
24
|
+
throw new Error(`Version ${feature.versions[0]} doesn't exist`)
|
|
25
|
+
}
|
|
26
|
+
if (maxVer === undefined) {
|
|
27
|
+
throw new Error(`Version ${feature.versions[1]} doesn't exist`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return minVer <= currentVer && currentVer <= maxVer
|
|
31
|
+
}
|