1
- import os
2
1
import json
3
- import zipfile
2
+ from shutil import make_archive
3
+ from pathlib import Path
4
4
5
5
# Goal: Write Datapack that sets up all display items
6
- VERSION = (1 , 0 , 0 ) # Major, Minor, Fix per semantic versioning v2 https://semver.org/
7
- MC_PACK_VERSION = 41
8
- DIR_OUTPUT = "./output"
9
- DIR_DATA = f"{ DIR_OUTPUT } /data"
10
- DIR_PACK = f"{ DIR_DATA } /summon-stands"
11
- DIR_FUNC = f"{ DIR_PACK } /functions"
12
- OUTPUT_FILE = f"summon-stands_{ MC_PACK_VERSION } _{ VERSION [0 ]} .{ VERSION [1 ]} .{ VERSION [2 ]} .zip"
6
+ VERSION = (1 , 0 , 1 ) # Major, Minor, Fix per semantic versioning v2 https://semver.org/
7
+ MC_PACK_VERSION = 61
8
+ DIR_OUTPUT = "./output/"
9
+ BUILD_DIR = "./output/build"
10
+ FUNC_DIR_NAME = "function"
11
+
12
+ DIR_DATA = f"{ BUILD_DIR } /data"
13
+ DIR_PACK = f"{ BUILD_DIR } /summon-stands"
14
+ MC_NAMESPACE = f"{ BUILD_DIR } /minecraft"
15
+ MC_FUNC = f"{ MC_NAMESPACE } /tags/{ FUNC_DIR_NAME } "
16
+ DIR_FUNC = f"{ DIR_PACK } /{ FUNC_DIR_NAME } "
17
+ OUTPUT_FILE = f"{ DIR_OUTPUT } /summon-stands_{ MC_PACK_VERSION } _{ VERSION [0 ]} .{ VERSION [1 ]} .{ VERSION [2 ]} "
13
18
armor_elements = ["boots" , "leggings" , "chestplate" , "helmet" ]
14
19
15
20
armor_class = ["leather" , "iron" , "diamond" , "golden" , "chainmail" , "netherite" ]
@@ -89,27 +94,24 @@ def makeSummon(x, y, z, material, trim, type):
89
94
out += "}"
90
95
return out
91
96
97
+ def checkDirectories ():
98
+ Path (DIR_FUNC ).mkdir (parents = True , exist_ok = True )
99
+ Path (MC_FUNC ).mkdir (parents = True , exist_ok = True )
100
+
101
+
102
+
92
103
def main ():
93
104
94
105
x_off = 1
95
106
y_off = 0
96
107
z_off = - 1
97
108
commands = []
98
-
99
- if not os .path .exists (DIR_OUTPUT ):
100
- os .mkdir (DIR_OUTPUT )
101
109
102
- if not os .path .exists (DIR_DATA ):
103
- os .mkdir (DIR_DATA )
104
-
105
- if not os .path .exists (DIR_PACK ):
106
- os .mkdir (DIR_PACK )
107
-
108
- if not os .path .exists (DIR_FUNC ):
109
- os .mkdir (DIR_FUNC )
110
+ checkDirectories ()
110
111
111
112
trim_x_off = 1
112
113
trim_commands = []
114
+ print ("BUILDING TRIM COMMANDS" )
113
115
for trim in trims :
114
116
# Generate Each Trim Type
115
117
for mat in materials :
@@ -132,17 +134,20 @@ def main():
132
134
for cmd in trim_commands :
133
135
file .write (cmd + "\n " )
134
136
# print(commands)
137
+ print ("#################################################################################" )
135
138
136
139
137
140
with open (f"{ DIR_FUNC } /load_all.mcfunction" , "w" ) as file :
141
+ print ("WRITING LOAD ALL FUNCTION" )
138
142
for cmd in commands :
139
143
file .write (cmd + "\n " )
140
144
141
145
# Add the load.mcfunction file
142
146
with open (f"{ DIR_FUNC } /load.mcfunction" , "w" ) as file :
147
+ print ("WRITING PACK LOAD FUNCTION" )
143
148
file .write ("# Load all functions" )
144
149
145
- with open (f"{ DIR_OUTPUT } /pack.mcmeta" , "w" ) as file :
150
+ with open (f"{ BUILD_DIR } /pack.mcmeta" , "w" ) as file :
146
151
print ("Writing Pack meta data" )
147
152
mcmeta = {
148
153
"pack" : {
@@ -151,15 +156,20 @@ def main():
151
156
}
152
157
}
153
158
json .dump (mcmeta , file , indent = 4 )
159
+
160
+ with open (f"{ MC_FUNC } /load.json" , "w" ) as file :
161
+ print ("Writing Minecraft Load JSON" )
162
+ mcload = {
163
+ "values" : [
164
+ "summon-stands:load"
165
+ ]
166
+ }
167
+
154
168
155
169
# Create ZIP
156
- final_output = zipfile .ZipFile (OUTPUT_FILE , "w" , zipfile .ZIP_DEFLATED )
157
- final_output .write (DIR_OUTPUT )
158
- with zipfile .ZipFile (OUTPUT_FILE , 'w' , zipfile .ZIP_DEFLATED ) as zfile :
159
- for folder , subs , files in os .walk (DIR_OUTPUT ):
160
- for file in files :
161
- p = os .path .join (folder , file )
162
- zfile .write (p , arcname = os .path .relpath (p , DIR_OUTPUT ))
170
+ print ("WRITING ZIP FILE" )
171
+ make_archive (OUTPUT_FILE , "zip" , BUILD_DIR )
172
+
163
173
164
174
165
175
if __name__ == "__main__" :
0 commit comments