-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
86 lines (73 loc) · 1.99 KB
/
main.go
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
package main
import (
"fmt"
"os"
"github.com/bbfh-dev/bubblellaneous-pack/bubblellaneous"
"github.com/bbfh-dev/bubblellaneous-pack/bubblellaneous/unit"
"github.com/bbfh-dev/bubblellaneous-pack/lib"
"github.com/bbfh-dev/bubblellaneous-pack/lib/code"
"github.com/bbfh-dev/bubblellaneous-pack/lib/lang"
"github.com/bbfh-dev/bubblellaneous-pack/lib/nbt"
)
const VERSION = "2.1.0"
func main() {
if len(os.Args) < 3 {
panic("Usage: main [output dir] [lang file]")
}
var registry = unit.NewCategory()
registry.
Add(bubblellaneous.Furniture.Units("furniture")...).
Add(bubblellaneous.Food.Units("food")...).
Add(bubblellaneous.Miscellaneous.Units("miscellaneous")...).
Add(bubblellaneous.Technology.Units("technology")...).
Sort()
customModelData := 371000
outputDir := os.Args[1]
resourceDir := os.Args[2]
langFile := os.Args[3]
tree := lib.NewTree(resourceDir)
for _, item := range registry.RawUnits() {
customModelData += unit.Compile(
item,
*code.NewTemplate("mcfunction"),
tree,
customModelData,
)
}
//region Baked block states
node := nbt.Tree()
for block, registry := range tree.StateRegistry {
if len(registry) == 0 {
continue
}
leaf := nbt.Tree()
for key, value := range registry {
leaf.Set(key, value.NBT())
}
node.Set(block, leaf)
}
code.NewTemplate("load_blockstates").
Replace("registry", node.String()).
Format().Write(tree)
//endregion
//region Bench registry
code.NewTemplate("registry").
Replace("version", VERSION).
Replace("furniture", tree.Furnitures().String()).
Replace("technology", tree.Technologies().String()).
Replace("food", tree.Foods().String()).
Replace("miscellaneous", tree.Miscellaneous().String()).
Format().Write(tree)
//endregistry
tree.WriteToFileSystem(outputDir)
fmt.Println(resourceDir)
fmt.Printf(
"Finished compiling %d units with %d models!\n",
len(registry.RawUnits()),
customModelData-371000,
)
tree.WriteLangFile(
outputDir,
lang.GetLangFile(lang.ReadFromFile(langFile)),
)
}