forked from michaljaz/webmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprebuild.js
More file actions
64 lines (53 loc) · 1.54 KB
/
prebuild.js
File metadata and controls
64 lines (53 loc) · 1.54 KB
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
/* eslint-disable no-new */
const version = '1.16.5'
const fs = require('fs')
const pBlock = require('prismarine-block')(version)
const AtlasCreator = require('./atlasCreator')
const path = require('path')
require('./merger.js')
require('./patch.js')
new AtlasCreator({
pref: 'items',
toxelSize: 50,
loadPath: path.join(__dirname, '../assets/items'),
buildPath: path.join(__dirname, '../src/assets/items'),
atlasSize: 32,
oneFrame: false
})
new AtlasCreator({
pref: 'blocks',
toxelSize: 16,
loadPath: path.join(__dirname, '../assets/pack/assets/minecraft/textures/block'),
buildPath: path.join(__dirname, '../src/assets/blocks'),
atlasSize: 36,
oneFrame: false
})
new AtlasCreator({
pref: 'blocksSnap',
toxelSize: 16,
loadPath: path.join(__dirname, '../assets/pack/assets/minecraft/textures/block'),
buildPath: path.join(__dirname, '../src/assets/blocks'),
atlasSize: 27,
oneFrame: true
})
let maxStateId = 0
for (let i = 0; i < 100000; i++) {
const block = pBlock.fromStateId(i)
if (block.type === undefined) {
maxStateId = i - 1
break
}
}
console.log(`\x1b[33mBlock max stateId: ${maxStateId}\x1b[0m`)
const result = []
for (let i = 0; i <= maxStateId; i++) {
const block = pBlock.fromStateId(i)
result.push([
block.name,
block.boundingBox === 'block' ? 1 : 0,
block.transparent ? 1 : 0
])
}
const buildPath = path.join(__dirname, '../src/assets/blocks/blocksDef.json')
fs.writeFileSync(buildPath, JSON.stringify(result))
console.log(`\x1b[32mGenerated blocksDefinitions: ${buildPath}\x1b[0m\n`)