-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (45 loc) · 1.79 KB
/
main.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
#imports
import json
import os
#gets the user's intended values and saves them
datapackpath = input("File Path> ")
datapackname = input("Name> ")
datapackversion = int(input("Version> "))
datapackdescription = input("Description> ")
#modifies the path to remove in text quotes
datapackname = datapackname.lower()
datapackpath = datapackpath.replace('"',"")
datapackname = datapackname.replace(' ',"_")
#makes the folder structure
datafolder = os.path.join(datapackpath,"data")
minecraftfolder = os.path.join(datafolder, "minecraft")
namespacefolder = os.path.join(datafolder, datapackname)
functionstagfolder = os.path.join(os.path.join(minecraftfolder, "tags"), "functions")
functionsfolder = os.path.join(namespacefolder,"functions")
craftfolder = os.path.join(functionsfolder, "craft")
os.mkdir(datafolder)
os.mkdir(minecraftfolder)
os.mkdir(namespacefolder)
os.mkdir(os.path.join(namespacefolder, "functions"))
os.mkdir(os.path.join(minecraftfolder, "tags"))
os.mkdir(functionstagfolder)
#mcmeta file generation
mcmeta = {"pack": {"pack_format": datapackversion,"description": datapackdescription}}
with open(os.path.join(datapackpath, "pack.mcmeta"), 'w') as outfile:
json.dump(mcmeta, outfile)
#creates the tag files
load = {"values": [f"{datapackname}:load"]}
tick = {"values": [f"{datapackname}:tick"]}
with open(os.path.join(functionstagfolder, "load.json"), 'w') as outfile:
json.dump(load, outfile)
with open(os.path.join(functionstagfolder, "tick.json"), 'w') as outfile:
json.dump(load, outfile)
#create the mcfunctions
load = ""
tick = ""
with open(os.path.join(functionsfolder, "load.mcfunction"),"w") as f:
f.write(load)
f.close()
with open(os.path.join(functionsfolder, "tick.mcfunction"),"w") as f:
f.write(tick)
f.close()