1

Simple datapack framework creator

Zero_4793's Avatar Zero_47938/28/23 6:17 am
1 emeralds 212 4
8/30/2023 6:42 pm
Zero_4793's Avatar Zero_4793
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.
Posted by Zero_4793's Avatar
Zero_4793
Level 54 : Grandmaster Technomancer
56

Create an account or sign in to comment.

4

1
08/29/2023 1:57 pm
Level 61 : High Grandmaster Sweetheart
imalittlhigh
imalittlhigh's Avatar
there are addons for vscode and the like, that create these directories for you ^^
Altho i just copy my "blank" pack ;D
1
08/29/2023 5:20 pm
Level 54 : Grandmaster Technomancer
Zero_4793
Zero_4793's Avatar
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
2
08/30/2023 4:59 am
Level 61 : High Grandmaster Sweetheart
imalittlhigh
imalittlhigh's Avatar
I have "MC Datapack by HuJohner" installed. Never rly use it, but looks to do the same your script does, just in vscode ^^
2
08/30/2023 6:42 pm
Level 54 : Grandmaster Technomancer
Zero_4793
Zero_4793's Avatar
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
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome