minecraft-data 3.13.0 → 3.14.1
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/doc/history.md +8 -0
- package/index.js +1 -1
- package/lib/supportsFeature.js +38 -50
- package/minecraft-data/data/bedrock/common/features.json +8 -1
- package/minecraft-data/data/pc/common/features.json +11 -1
- package/minecraft-data/doc/history.md +6 -0
- package/package.json +1 -1
- package/test/load.js +13 -0
package/doc/history.md
CHANGED
package/index.js
CHANGED
|
@@ -68,7 +68,7 @@ module.exports = function (mcVersion, preNetty) {
|
|
|
68
68
|
nmcData.isOlderThan = version => nmcData.version['<'](version)
|
|
69
69
|
nmcData.version = Object.assign(majorVersion, nmcData.version)
|
|
70
70
|
cache[cachedName] = nmcData
|
|
71
|
-
nmcData.supportFeature =
|
|
71
|
+
nmcData.supportFeature = supportFeature(nmcData.version, protocolVersions[nmcData.type])
|
|
72
72
|
return nmcData
|
|
73
73
|
}
|
|
74
74
|
|
package/lib/supportsFeature.js
CHANGED
|
@@ -1,63 +1,51 @@
|
|
|
1
|
-
const features =
|
|
2
|
-
|
|
1
|
+
const features = {
|
|
2
|
+
pc: require('../minecraft-data/data/pc/common/features.json'),
|
|
3
|
+
bedrock: require('../minecraft-data/data/bedrock/common/features.json')
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
module.exports = (versionObj, allVersions) => {
|
|
7
|
+
// Keep a dictionary of majorVersion => oldest / newest release
|
|
8
|
+
// Relies on descending order in minecraft-data's protocolVersions list
|
|
9
|
+
const newestMajor = allVersions.reduce((acc, cur) => { acc[cur.majorVersion] = acc[cur.majorVersion] || cur; return acc }, {})
|
|
10
|
+
const oldestMajor = allVersions.reduce((acc, cur) => { acc[cur.majorVersion] = cur; return acc }, {})
|
|
11
|
+
|
|
12
|
+
function isVersionInRange (minVer, maxVer) {
|
|
13
|
+
if (minVer.endsWith('_major')) {
|
|
14
|
+
minVer = oldestMajor[removeMajorSuffix(minVer)].minecraftVersion
|
|
15
|
+
}
|
|
16
|
+
if (maxVer.endsWith('_major')) {
|
|
17
|
+
maxVer = newestMajor[removeMajorSuffix(maxVer)].minecraftVersion
|
|
18
|
+
} else if (maxVer === 'latest') {
|
|
19
|
+
return versionObj['>='](minVer)
|
|
20
|
+
}
|
|
3
21
|
|
|
4
|
-
|
|
5
|
-
const feature = nameToFeature[featureName]
|
|
6
|
-
if (feature === undefined) {
|
|
7
|
-
throw new Error(`Feature ${feature} doesn't exist`)
|
|
22
|
+
return versionObj['>='](minVer) && versionObj['<='](maxVer)
|
|
8
23
|
}
|
|
9
24
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} else { // we're using feature.versions
|
|
21
|
-
const [minVer, maxVer] = versions
|
|
22
|
-
if (isVersionInRange(minVer, versionObj, maxVer)) {
|
|
23
|
-
return value
|
|
25
|
+
const featureList = features[versionObj.type].map(feature => [feature.name, feature])
|
|
26
|
+
|
|
27
|
+
const map = {}
|
|
28
|
+
for (const [featureName, feature] of featureList) {
|
|
29
|
+
if (feature.values) {
|
|
30
|
+
for (const { value, versions, version } of feature.values) { // we're using feature.version
|
|
31
|
+
if (version) {
|
|
32
|
+
if (isVersionInRange(version, version)) map[featureName] = value
|
|
33
|
+
} else {
|
|
34
|
+
if (isVersionInRange(...versions)) map[featureName] = value
|
|
24
35
|
}
|
|
25
36
|
}
|
|
37
|
+
} else {
|
|
38
|
+
const [minVer, maxVer] = feature.versions
|
|
39
|
+
map[featureName] = isVersionInRange(minVer, maxVer)
|
|
26
40
|
}
|
|
27
|
-
return null // if we didn't match anything, return null
|
|
28
|
-
} else {
|
|
29
|
-
const [minVer, maxVer] = feature.versions
|
|
30
|
-
return isVersionInRange(minVer, versionObj, maxVer)
|
|
31
41
|
}
|
|
32
|
-
}
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
let inRange = true
|
|
36
|
-
const { majorVersion } = versionObj
|
|
37
|
-
if (minVer.endsWith('_major')) {
|
|
38
|
-
const ver = removeMajorSuffix(minVer)
|
|
39
|
-
inRange = inRange && getVersionObj(majorVersion)['>='](ver)
|
|
40
|
-
} else {
|
|
41
|
-
inRange = inRange && versionObj['>='](minVer)
|
|
42
|
-
}
|
|
43
|
-
if (maxVer === 'latest') { // no need to check upper bound if upperbound is latest
|
|
44
|
-
return inRange
|
|
45
|
-
}
|
|
46
|
-
if (maxVer.endsWith('_major')) {
|
|
47
|
-
const ver = removeMajorSuffix(maxVer)
|
|
48
|
-
inRange = inRange && getVersionObj(majorVersion)['<='](ver)
|
|
49
|
-
} else {
|
|
50
|
-
inRange = inRange && versionObj['<='](maxVer)
|
|
51
|
-
}
|
|
52
|
-
return inRange
|
|
43
|
+
return featureName => map[featureName] || false
|
|
53
44
|
}
|
|
54
45
|
|
|
55
46
|
function removeMajorSuffix (verStr) {
|
|
47
|
+
if (!/^\d\.\d+_major$/.test(verStr)) {
|
|
48
|
+
throw new Error(`Not a correct major version value: "${verStr}"`)
|
|
49
|
+
}
|
|
56
50
|
return verStr.replace('_major', '')
|
|
57
51
|
}
|
|
58
|
-
|
|
59
|
-
function getVersionObj (ver) {
|
|
60
|
-
return require('minecraft-data')(ver).version
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = isFeatureInRange
|
|
@@ -57,7 +57,12 @@
|
|
|
57
57
|
{
|
|
58
58
|
"name": "dimensionDataIsAvailable",
|
|
59
59
|
"description": "dimensionData is available, providing an additional information about the current dimension",
|
|
60
|
-
"versions": ["1.17", "1.
|
|
60
|
+
"versions": ["1.17", "1.18.2"]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "dimensionDataInCodec",
|
|
64
|
+
"description": "dimensionData like world height is exclusively in the codec in login packet",
|
|
65
|
+
"versions": ["1.19", "latest"]
|
|
61
66
|
},
|
|
62
67
|
{
|
|
63
68
|
"name": "useItemWithBlockPlace",
|
|
@@ -446,5 +451,10 @@
|
|
|
446
451
|
"name": "signatureEncryption",
|
|
447
452
|
"description": "allows for usage of `signature` instead of verifyToken in serverbound packet_encryption_begin",
|
|
448
453
|
"versions": ["1.19_major", "latest"]
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"name": "clientboundChatHasSender",
|
|
457
|
+
"description": "clientbound chat packet contains message sender's UUID",
|
|
458
|
+
"versions": ["1.16_major", "latest"]
|
|
449
459
|
}
|
|
450
460
|
]
|
package/package.json
CHANGED
package/test/load.js
CHANGED
|
@@ -81,4 +81,17 @@ describe('supportFeature', () => {
|
|
|
81
81
|
assert.equal(newVal, v, `Failed on mc version ${k} | Expected: ${v}, Got: ${newVal}`)
|
|
82
82
|
}
|
|
83
83
|
})
|
|
84
|
+
|
|
85
|
+
it('handles "_major" correctly on itemSerializationUsesBlockId', function () {
|
|
86
|
+
const mcData1Dot9 = require('minecraft-data')('1.9')
|
|
87
|
+
const mcData1Dot17 = require('minecraft-data')('1.12.2')
|
|
88
|
+
assert.equal(mcData1Dot9.supportFeature('itemSerializationUsesBlockId'), true)
|
|
89
|
+
assert.equal(mcData1Dot17.supportFeature('itemSerializationUsesBlockId'), true)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('works on bedrock', function () {
|
|
93
|
+
const mcData = require('minecraft-data')('bedrock_1.18.0')
|
|
94
|
+
assert.equal(mcData.supportFeature('newRecipeSchema'), true)
|
|
95
|
+
assert.equal(mcData.supportFeature('fakeRecipeSchema'), false)
|
|
96
|
+
})
|
|
84
97
|
})
|