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
60 lines (49 loc) · 1.44 KB
/
prebuild.js
File metadata and controls
60 lines (49 loc) · 1.44 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
var version = "1.16.5";
var fs = require("fs");
var pBlock = require("prismarine-block")(version);
var 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/pack/assets/minecraft/textures/block`,
buildPath: `${__dirname}/client/assets/blocks`,
atlasSize: 36,
oneFrame: false,
});
new atlasCreator({
pref: "blocksSnap",
toxelSize: 16,
loadPath: `${__dirname}/assets/pack/assets/minecraft/textures/block`,
buildPath: `${__dirname}/client/assets/blocks`,
atlasSize: 27,
oneFrame: true,
});
var maxStateId = 0;
for (var i = 0; i < 100000; i++) {
var block = pBlock.fromStateId(i);
if (block.type === void 0) {
maxStateId = i - 1;
break;
}
}
console.log(`\x1b[33mBlock max stateId: ${maxStateId}\x1b[0m`);
var result = [];
for (let i = 0; i <= maxStateId; i++) {
block = pBlock.fromStateId(i);
result.push([
block.name,
block.boundingBox === "block" ? 1 : 0,
block.transparent ? 1 : 0,
]);
}
var buildPath = `${__dirname}/client/assets/blocks/blocksDef.json`;
fs.writeFileSync(buildPath, JSON.stringify(result));
console.log(`\x1b[32mGenerated blocksDefinitions: ${buildPath}\x1b[0m\n`);