mcdevs-wiki-extractor 0.2.0 → 0.3.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/.github/dependabot.yml +14 -0
- package/.github/workflows/ci.yml +25 -0
- package/.github/workflows/commands.yml +22 -0
- package/.github/workflows/publish.yml +34 -0
- package/README.md +35 -3
- package/bin/entities_to_json.js +12 -12
- package/bin/protocol_comments_to_json.js +11 -11
- package/bin/protocol_to_json.js +11 -11
- package/index.js +4 -4
- package/lib/common/table_parser.js +75 -95
- package/lib/common/toOldNames.js +98 -0
- package/lib/entities_extractor.js +54 -48
- package/lib/protocol_extractor.js +286 -428
- package/lib/relink.js +10 -0
- package/package.json +8 -4
- package/test/test_protocol_extractor.js +220 -221
- package/.npmignore +0 -1
- package/circle.yml +0 -3
|
@@ -1,68 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const WikiTextParser = require('parse-wikitext')
|
|
2
|
+
const fs = require('fs')
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const wikiTextParser = new WikiTextParser('wiki.vg')
|
|
5
5
|
|
|
6
|
-
module.exports={writeAllEntities:writeAllEntities,getEntities:getEntities}
|
|
6
|
+
module.exports = { writeAllEntities: writeAllEntities, getEntities: getEntities }
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const tableParser = require('./common/table_parser')
|
|
9
9
|
|
|
10
|
-
function getEntities(date,cb)
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
function getEntities (date, cb) {
|
|
11
|
+
wikiTextParser.getFixedArticle('Entity_metadata', date, function (err, pageData, title) {
|
|
12
|
+
if (err) {
|
|
13
|
+
cb(err)
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
const sectionObject = wikiTextParser.pageToSectionObject(pageData)
|
|
17
|
+
const mobs = sectionObject.Mobs.content
|
|
18
|
+
const objects = sectionObject.Objects.content
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
let parsedMobs = tableParser.parseWikiTable(tableParser.getFirstTable(mobs))
|
|
21
|
+
let parsedObjects = tableParser.parseWikiTable(tableParser.getFirstTable(objects))
|
|
19
22
|
|
|
20
|
-
function transformSize(size) {
|
|
21
|
-
if(size
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
return parseFloat(r[1]);
|
|
23
|
+
function transformSize (size) {
|
|
24
|
+
if (size === 'N/A') { return null }
|
|
25
|
+
let r = size.match(/^(.+?) \* size/)
|
|
26
|
+
if (r) {
|
|
27
|
+
return parseFloat(r[1])
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
return parseFloat(r[1])*parseFloat(r[2])
|
|
29
|
+
r = size.match(/^(.+?) \* (.+?)/)
|
|
30
|
+
if (r) {
|
|
31
|
+
return parseFloat(r[1]) * parseFloat(r[2])
|
|
31
32
|
}
|
|
32
|
-
return parseFloat(size)
|
|
33
|
+
return parseFloat(size)
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
parsedMobs = parsedMobs.map(function (val) {
|
|
36
37
|
return {
|
|
37
|
-
id:parseInt(val
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
id: parseInt(val.Type),
|
|
39
|
+
internalId: parseInt(val.Type),
|
|
40
|
+
name: val.ID ? val.ID.replace(/<code>(.+)<\/code>/, '$1').replace(/minecraft:/g, '') : undefined,
|
|
41
|
+
displayName: val.Name,
|
|
42
|
+
width: transformSize(val['bounding box x and z']),
|
|
43
|
+
height: transformSize(val['bounding box y']),
|
|
44
|
+
type: 'mob'
|
|
43
45
|
}
|
|
44
|
-
})
|
|
46
|
+
})
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
parsedObjects = parsedObjects.map(function (val) {
|
|
47
49
|
return {
|
|
48
|
-
id:parseInt(val
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
id: parseInt(val.ID),
|
|
51
|
+
internalId: parseInt(val.ID),
|
|
52
|
+
name: val.Name.replace(/\(.+?\)/, '').trim().replace(/ /, '_').toLowerCase(),
|
|
53
|
+
displayName: val.Name,
|
|
54
|
+
width: transformSize(val['bounding box x and z']),
|
|
55
|
+
height: transformSize(val['bounding box y']),
|
|
56
|
+
type: 'object'
|
|
53
57
|
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
var entities=parsed_mobs.concat(parsed_objects);
|
|
58
|
+
})
|
|
57
59
|
|
|
60
|
+
const entities = parsedMobs.concat(parsedObjects)
|
|
58
61
|
|
|
59
|
-
cb(null,entities)
|
|
60
|
-
})
|
|
62
|
+
cb(null, entities)
|
|
63
|
+
})
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
function writeAllEntities(file,date, cb)
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
function writeAllEntities (file, date, cb) {
|
|
67
|
+
getEntities(date, function (err, entities) {
|
|
68
|
+
if (err) {
|
|
69
|
+
cb(err)
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
fs.writeFile(file, JSON.stringify(entities, null, 2), cb)
|
|
73
|
+
})
|
|
68
74
|
}
|