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
80 lines (65 loc) · 1.48 KB
/
prebuild.js
File metadata and controls
80 lines (65 loc) · 1.48 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var atlasCreator,
block,
buildPath,
config,
fs,
i,
j,
k,
maxStateId,
pBlock,
ref,
result;
fs = require("fs");
config = require("./server.json");
pBlock = require("prismarine-block")(config.version);
atlasCreator = require("./atlasCreator");
new atlasCreator({
pref: "items",
toxelSize: 50,
loadPath: `${__dirname}/assets/items`,
buildPath: `${__dirname}/client/assets/items`,
atlasSize: 32,
oneFrame: false,
});
new atlasCreator({
pref: "blocks",
toxelSize: 16,
loadPath: `${__dirname}/assets/blocks`,
buildPath: `${__dirname}/client/assets/blocks`,
atlasSize: 36,
oneFrame: false,
});
new atlasCreator({
pref: "blocksSnap",
toxelSize: 16,
loadPath: `${__dirname}/assets/blocks`,
buildPath: `${__dirname}/client/assets/blocks`,
atlasSize: 27,
oneFrame: true,
});
maxStateId = 0;
for (i = j = 0; j <= 100000; i = ++j) {
block = pBlock.fromStateId(i);
if (block.type === void 0) {
maxStateId = i - 1;
break;
}
}
console.log(`\x1b[33mBlock max stateId: ${maxStateId}\x1b[0m`);
result = [];
for (
i = k = 0, ref = maxStateId;
0 <= ref ? k <= ref : k >= ref;
i = 0 <= ref ? ++k : --k
) {
block = pBlock.fromStateId(i);
result.push([
block.name,
block.boundingBox === "block" ? 1 : 0,
block.transparent ? 1 : 0,
]);
}
buildPath = `${__dirname}/client/assets/blocks/blocksDef.json`;
fs.writeFileSync(buildPath, JSON.stringify(result));
console.log(`\x1b[32mGenerated blocksDefinitions: ${buildPath}\x1b[0m\n`);