1
I don't know if something like this already exists. But i couldn't find one so i decided to make one.
Below is a simple python script for initialising new datapack directories, to save the hassle of setting all those names in all those places.
Remember to change the hardcoded <namespace> and <version> values in the script.
create_datapack.py
```
# Datapack creatorimport os
# simple cmd console that takes an input <name> and creates a datapack base with that name
# hardcode your namespace and current version herenamespace = "<namespace>"version = "15"
def main(): while True: name = input("Enter name of datapack: ") #validate name if name == "": print("Please enter a name.") # check length elif len(name) > 32: print("Name must be less than 32 characters.") # check no spaces elif " " in name: print("Name cannot contain spaces.") #check for illegal characters elif not all(c in "abcdefghijklmnopqrstuvwxyz0123456789_-." for c in name): print("Name contains illegal characters.") elif os.path.exists(name): print("A folder with this name already exists. Please choose another name.") continue else: break create_datapack(name)
def create_datapack(name): # create dirs os.makedirs(name + "/data/minecraft/tags/functions") os.makedirs(name + "/data/" + namespace + "/functions/" + name)
# pack.mcmeta f = open(name + "/pack.mcmeta", "w") f.write("{\n\t\"pack\": {\n\t\t\"pack_format\": " + version + ",\n\t\t\"description\": \"" + namespace + "." + name + "\"\n\t}\n}") f.close()
# load.json f = open(name + "/data/minecraft/tags/functions/load.json", "w") f.write("{\n\t\"replace\": false,\n\t\"values\": [\n\t\t\"" + namespace + ":" + name + "/init\"\n\t]\n}") f.close()
# tick.json f = open(name + "/data/minecraft/tags/functions/tick.json", "w") f.write("{\n\t\"replace\": false,\n\t\"values\": [\n\t\t\"" + namespace + ":" + name + "/core\"\n\t]\n}") f.close()
# init.mcfunction f = open(name + "/data/" + namespace + "/functions/" + name + "/init.mcfunction", "w") # tellraw @a {"text":"<name> Datapack loaded!","color":"green"} f.write("tellraw @a {\"text\":\"" + name + " Datapack loaded!\",\"color\":\"green\"}") f.close()
# core.mcfunction open(name + "/data/" + namespace + "/functions/" + name + "/core.mcfunction", "w").close()
main()```
not sure how to upload straight file, so here is code. simply copy paste into a 'create_datapack.py' edit namespace, run by double-clicking. Should be that easy if you have python.
Below is a simple python script for initialising new datapack directories, to save the hassle of setting all those names in all those places.
Remember to change the hardcoded <namespace> and <version> values in the script.
create_datapack.py
```
# Datapack creatorimport os
# simple cmd console that takes an input <name> and creates a datapack base with that name
# hardcode your namespace and current version herenamespace = "<namespace>"version = "15"
def main(): while True: name = input("Enter name of datapack: ") #validate name if name == "": print("Please enter a name.") # check length elif len(name) > 32: print("Name must be less than 32 characters.") # check no spaces elif " " in name: print("Name cannot contain spaces.") #check for illegal characters elif not all(c in "abcdefghijklmnopqrstuvwxyz0123456789_-." for c in name): print("Name contains illegal characters.") elif os.path.exists(name): print("A folder with this name already exists. Please choose another name.") continue else: break create_datapack(name)
def create_datapack(name): # create dirs os.makedirs(name + "/data/minecraft/tags/functions") os.makedirs(name + "/data/" + namespace + "/functions/" + name)
# pack.mcmeta f = open(name + "/pack.mcmeta", "w") f.write("{\n\t\"pack\": {\n\t\t\"pack_format\": " + version + ",\n\t\t\"description\": \"" + namespace + "." + name + "\"\n\t}\n}") f.close()
# load.json f = open(name + "/data/minecraft/tags/functions/load.json", "w") f.write("{\n\t\"replace\": false,\n\t\"values\": [\n\t\t\"" + namespace + ":" + name + "/init\"\n\t]\n}") f.close()
# tick.json f = open(name + "/data/minecraft/tags/functions/tick.json", "w") f.write("{\n\t\"replace\": false,\n\t\"values\": [\n\t\t\"" + namespace + ":" + name + "/core\"\n\t]\n}") f.close()
# init.mcfunction f = open(name + "/data/" + namespace + "/functions/" + name + "/init.mcfunction", "w") # tellraw @a {"text":"<name> Datapack loaded!","color":"green"} f.write("tellraw @a {\"text\":\"" + name + " Datapack loaded!\",\"color\":\"green\"}") f.close()
# core.mcfunction open(name + "/data/" + namespace + "/functions/" + name + "/core.mcfunction", "w").close()
main()```
not sure how to upload straight file, so here is code. simply copy paste into a 'create_datapack.py' edit namespace, run by double-clicking. Should be that easy if you have python.
Create an account or sign in to comment.
4
1
there are addons for vscode and the like, that create these directories for you ^^
Altho i just copy my "blank" pack ;D
Altho i just copy my "blank" pack ;D
1
I tried looking on vscode and didnt find any. guess i didnt look hard enough.
but also blank doesnt help as you still gotta set the name in several places
but also blank doesnt help as you still gotta set the name in several places
2
I have "MC Datapack by HuJohner" installed. Never rly use it, but looks to do the same your script does, just in vscode ^^
2
Thank you, that does look similar, however i think ill continue using mine as ive already customized it to have some of my own specific defaults