-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
159 lines (152 loc) · 7.37 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const mcDataToNode = require('./lib/loader')
const cache = {} // prevent reindexing when requiring multiple time the same version
function getVersion (mcVersion) {
if (cache[mcVersion]) { return cache[mcVersion] }
const mcData = data[mcVersion]
if (mcData == null) { return null }
const nmcData = mcDataToNode(mcData, mcVersion)
cache[mcVersion] = nmcData
return nmcData
}
function toMajor (version) {
const [a, b] = (version + '').split('.')
return a + '.' + b
}
function minor (version) {
const [, , c] = (version + '.0').split('.')
return parseInt(c, 10)
}
module.exports = function (mcVersion) {
// Check exact version first
let assets = getVersion(mcVersion)
if (assets) { return assets }
// If not found, resort to the last of major
assets = getVersion(lastOfMajor[toMajor(mcVersion)])
return assets
}
const data = {
'1.8.8': {
blocksTextures: require('./minecraft-assets/data/1.8.8/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.8.8/items_textures'),
textureContent: require('./minecraft-assets/data/1.8.8/texture_content'),
blocksStates: require('./minecraft-assets/data/1.8.8/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.8.8/blocks_models')
},
1.9: {
blocksTextures: require('./minecraft-assets/data/1.9/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.9/items_textures'),
textureContent: require('./minecraft-assets/data/1.9/texture_content'),
blocksStates: require('./minecraft-assets/data/1.9/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.9/blocks_models')
},
'1.10': {
blocksTextures: require('./minecraft-assets/data/1.10/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.10/items_textures'),
textureContent: require('./minecraft-assets/data/1.10/texture_content'),
blocksStates: require('./minecraft-assets/data/1.10/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.10/blocks_models')
},
'1.11.2': {
blocksTextures: require('./minecraft-assets/data/1.11.2/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.11.2/items_textures'),
textureContent: require('./minecraft-assets/data/1.11.2/texture_content'),
blocksStates: require('./minecraft-assets/data/1.11.2/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.11.2/blocks_models')
},
1.12: {
blocksTextures: require('./minecraft-assets/data/1.12/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.12/items_textures'),
textureContent: require('./minecraft-assets/data/1.12/texture_content'),
blocksStates: require('./minecraft-assets/data/1.12/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.12/blocks_models')
},
1.13: {
blocksTextures: require('./minecraft-assets/data/1.13/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.13/items_textures'),
textureContent: require('./minecraft-assets/data/1.13/texture_content'),
blocksStates: require('./minecraft-assets/data/1.13/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.13/blocks_models')
},
'1.13.2': {
blocksTextures: require('./minecraft-assets/data/1.13.2/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.13.2/items_textures'),
textureContent: require('./minecraft-assets/data/1.13.2/texture_content'),
blocksStates: require('./minecraft-assets/data/1.13.2/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.13.2/blocks_models')
},
'1.14.4': {
blocksTextures: require('./minecraft-assets/data/1.14.4/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.14.4/items_textures'),
textureContent: require('./minecraft-assets/data/1.14.4/texture_content'),
blocksStates: require('./minecraft-assets/data/1.14.4/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.14.4/blocks_models')
},
'1.15.2': {
blocksTextures: require('./minecraft-assets/data/1.15.2/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.15.2/items_textures'),
textureContent: require('./minecraft-assets/data/1.15.2/texture_content'),
blocksStates: require('./minecraft-assets/data/1.15.2/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.15.2/blocks_models')
},
'1.16.1': {
blocksTextures: require('./minecraft-assets/data/1.16.1/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.16.1/items_textures'),
textureContent: require('./minecraft-assets/data/1.16.1/texture_content'),
blocksStates: require('./minecraft-assets/data/1.16.1/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.16.1/blocks_models')
},
'1.16.4': {
blocksTextures: require('./minecraft-assets/data/1.16.4/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.16.4/items_textures'),
textureContent: require('./minecraft-assets/data/1.16.4/texture_content'),
blocksStates: require('./minecraft-assets/data/1.16.4/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.16.4/blocks_models')
},
'1.17.1': {
blocksTextures: require('./minecraft-assets/data/1.17.1/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.17.1/items_textures'),
textureContent: require('./minecraft-assets/data/1.17.1/texture_content'),
blocksStates: require('./minecraft-assets/data/1.17.1/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.17.1/blocks_models')
},
'1.18.1': {
blocksTextures: require('./minecraft-assets/data/1.18.1/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.18.1/items_textures'),
textureContent: require('./minecraft-assets/data/1.18.1/texture_content'),
blocksStates: require('./minecraft-assets/data/1.18.1/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.18.1/blocks_models')
},
'1.19.1': {
blocksTextures: require('./minecraft-assets/data/1.19.1/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.19.1/items_textures'),
textureContent: require('./minecraft-assets/data/1.19.1/texture_content'),
blocksStates: require('./minecraft-assets/data/1.19.1/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.19.1/blocks_models')
},
'1.20.2': {
blocksTextures: require('./minecraft-assets/data/1.20.2/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.20.2/items_textures'),
textureContent: require('./minecraft-assets/data/1.20.2/texture_content'),
blocksStates: require('./minecraft-assets/data/1.20.2/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.20.2/blocks_models')
},
'1.21.1': {
blocksTextures: require('./minecraft-assets/data/1.21.1/blocks_textures'),
itemsTextures: require('./minecraft-assets/data/1.21.1/items_textures'),
textureContent: require('./minecraft-assets/data/1.21.1/texture_content'),
blocksStates: require('./minecraft-assets/data/1.21.1/blocks_states'),
blocksModels: require('./minecraft-assets/data/1.21.1/blocks_models')
}
}
module.exports.versions = Object.keys(data)
const lastOfMajor = {}
for (const version in data) {
const major = toMajor(version)
if (lastOfMajor[major]) {
if (minor(lastOfMajor[major]) < minor(version)) {
lastOfMajor[major] = version
}
} else {
lastOfMajor[major] = version
}
}