-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenJson.py
102 lines (86 loc) · 2.49 KB
/
genJson.py
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
PIPES = [
"white_stained_pipe",
"orange_stained_pipe",
"magenta_stained_pipe",
"light_blue_stained_pipe",
"yellow_stained_pipe",
"lime_stained_pipe",
"pink_stained_pipe",
"gray_stained_pipe",
"light_gray_stained_pipe",
"cyan_stained_pipe",
"purple_stained_pipe",
"blue_stained_pipe",
"brown_stained_pipe",
"green_stained_pipe",
"red_stained_pipe",
"black_stained_pipe",
"filtered_pipe_whitelist",
"filtered_pipe_blacklist",
"pipe"
]
blockstatesDir = "src/main/resources/assets/ezpas/blockstates/"
modelsDir = "src/main/resources/assets/ezpas/models/"
blockModelsDir = modelsDir + "block/pipe/"
itemModelsDir = modelsDir + "item/"
def write_json(path, json):
f = open(path, "w")
f.write(json)
f.close()
def bs_json(name):
return """{{
\"multipart\": [
{{
\"apply\": {{ \"model\": \"ezpas:block/pipe/{}_center\" }}
}},
{{
\"when\": {{ \"north\": true }},
\"apply\": {{ \"model\": \"ezpas:block/pipe/{}_side\" }}
}},
{{
\"when\": {{ \"east\": true }},
\"apply\": {{ \"model\": \"ezpas:block/pipe/{}_side\", \"y\": 90 }}
}},
{{
\"when\": {{ \"south\": true }},
\"apply\": {{ \"model\": \"ezpas:block/pipe/{}_side\", \"y\": 180 }}
}},
{{
\"when\": {{ \"west\": true }},
\"apply\": {{ \"model\": \"ezpas:block/pipe/{}_side\", \"y\": 270 }}
}},
{{
\"when\": {{ \"up\": true }},
\"apply\": {{ \"model\": \"ezpas:block/pipe/{}_side\", \"x\": 270}}
}},
{{
\"when\": {{ \"down\": true }},
\"apply\": {{ \"model\": \"ezpas:block/pipe/{}_side\", \"x\": 90 }}
}}
]
}}""".format(name, name, name, name, name, name, name)
def pipe_center_json(name):
return """{{
"parent": "ezpas:block/template/pipe_center",
"textures": {{
"pipe": "ezpas:block/{}"
}}
}}""".format(name)
def pipe_side_json(name):
return """{{
"parent": "ezpas:block/template/pipe_side",
"textures": {{
"pipe": "ezpas:block/{}"
}}
}}""".format(name)
def item_json(name):
return """{{
"parent": "ezpas:block/pipe/{}_center"
}}""".format(name)
def write_pipe(name):
write_json("{}{}.json".format(blockstatesDir, name), bs_json(name))
write_json("{}{}_center.json".format(blockModelsDir, name), pipe_center_json(name))
write_json("{}{}_side.json".format(blockModelsDir, name), pipe_side_json(name))
write_json("{}{}.json".format(itemModelsDir, name), item_json(name))
for pipe in PIPES:
write_pipe(pipe)