Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-wals committed Jul 29, 2022
2 parents ba2ec77 + 0be5552 commit a17768e
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 674 deletions.
162 changes: 55 additions & 107 deletions ADVA.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,30 @@ def get_size(fileobject):
return size

# defines the advancement fucntion
def ADV():

# grabs info from from the advaconfig file
advaconfig = open("C:/Users/" + getpass.getuser() + "/AppData/Roaming/Totems+/advaconfig.txt", "r")
advaconfigread = advaconfig.readlines()
advaconfig.close()

# sorts info into appropriate variables
worldLocation = advaconfigread[0]
nameList = advaconfigread[1]
name = advaconfigread[2]

# creates lists with nessesary values
worldLocation = worldLocation.replace('\n','')
nameList = nameList.split(';')
def ADV(worldLocation, nameList, name):

# checks if the totems plus directory exists and if not creates one
file_exists = os.path.exists(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus')

if file_exists != True:

if not os.path.exists(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus'):
os.mkdir(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus')

os.mkdir(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements')

######

# sets the backround image to the original variable
original = 'img/totemwave.png'

# creates the needed directories in the resource pack
os.mkdir("C:/Users/" + getpass.getuser() + "/AppData/Roaming/.minecraft/resourcepacks/" + name + "/assets/minecraft/textures/gui")
os.mkdir("C:/Users/" + getpass.getuser() + "/AppData/Roaming/.minecraft/resourcepacks/" + name + "/assets/minecraft/textures/gui/advancements")

# sets the target destination
target = "C:/Users/" + getpass.getuser() + "/AppData/Roaming/.minecraft/resourcepacks/" + name + "/assets/minecraft/textures/gui/advancements"

# coppies the file
shutil.copy(original, target)
shutil.copy('img/totemwave.png', "C:/Users/" + getpass.getuser() + "/AppData/Roaming/.minecraft/resourcepacks/" + name + "/assets/minecraft/textures/gui/advancements")

######

# creates the root advancement
collectall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/root.json', 'x')
collectall.close()

collectall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/root.json', 'a')
root = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/root.json', 'w+')

# writes needed json to the root file
collectall.writelines(['{\n',
root.writelines(['{\n',
' "__comment": "Made by the Totems+ Team",\n',
' "display": {\n',
' "title": {\n',
Expand Down Expand Up @@ -106,10 +80,7 @@ def ADV():
######

# creates the collect all advancement
collectall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/collectall.json', 'x')
collectall.close()

collectall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/collectall.json', 'a')
collectall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/collectall.json', 'w+')

# writes start un-varied meta to file
collectall.writelines(['{\n',
Expand All @@ -132,30 +103,28 @@ def ADV():
' "announce_to_chat": true,\n',
' "hidden": false\n',
' },\n',
' "criteria": {\n'])

# sets the counter to 0
counter = 0
' "criteria": {'])

# loops through name list
while len(nameList) != counter + 1:
for i in range(len(nameList)):

# writes the varied meta to the file
collectall.write('\n "Collect' + nameList[counter] + '": {\n')
collectall.writelines([' "trigger": "minecraft:inventory_changed",\n',
collectall.writelines(['\n "Collect' + nameList[i] + '": {\n',
' "trigger": "minecraft:inventory_changed",\n',
' "conditions": {\n',
' "items": [\n',
' {\n',
' "item": "minecraft:totem_of_undying",\n'])
collectall.write(' "nbt": "{CustomModelData:' + str(910340 + counter) + '}"\n')
collectall.write(' "nbt": "{CustomModelData:' + str(910340 + i) + '}"\n')
collectall.writelines([' }\n',
' ]\n',
' }\n',
' },'])

# increases the counter by 1
counter += 1

# re opens file in correct mode
collectall.close()
collectall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/collectall.json', 'a')

# removes the last "," cuz json
fsize = get_size(collectall)
collectall.truncate(fsize - 1)
Expand All @@ -164,15 +133,13 @@ def ADV():
collectall.writelines(['\n },\n',
' "parent": "totemsplus:root"\n',
'}'])
collectall.close()

#####

# creates the use all advancement
useall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/useall.json', 'x')
useall.close()

useall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/useall.json', 'a')

useall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/useall.json', 'w+')

# writes start un-varied meta to file
useall.writelines(['{\n',
' "__comment": "Made by the Totems+ Team",\n',
Expand All @@ -194,27 +161,25 @@ def ADV():
' "announce_to_chat": true,\n',
' "hidden": false\n',
' },\n',
' "criteria": {\n'])

# re-sets counter to 0
counter = 0
' "criteria": {'])

# loops through name list
while len(nameList) != counter + 1:
for i in range(len(nameList)):

# writes the varied meta to the file
useall.write('\n "Use' + nameList[counter] + '": {\n')
useall.writelines([' "trigger": "minecraft:used_totem",\n',
useall.writelines(['\n "Use' + nameList[i] + '": {\n',
' "trigger": "minecraft:used_totem",\n',
' "conditions": {\n',
' "item": {\n',
' "item": "minecraft:totem_of_undying",\n'])
useall.write(' "nbt": "{CustomModelData:' + str(910340 + counter) + '}"\n')
useall.write(' "nbt": "{CustomModelData:' + str(910340 + i) + '}"\n')
useall.writelines([' }\n',
' }\n',
' },'])

# increases the counter by 1
counter += 1
# re opens file in correct mode
useall.close()
useall = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/useall.json', 'a')

# removes the last "," cuz json
fsize = get_size(useall)
Expand All @@ -224,51 +189,46 @@ def ADV():
useall.writelines(['\n },\n',
' "parent": "totemsplus:root"\n',
'}'])
useall.close()

#####

# re-sets the counter to 0
counter = 0

# cycles throught the name list
while len(nameList) != counter + 1:
for i in range(len(nameList)):

# creates the collect totem advancement
collecttotem = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/collect' + nameList[counter].lower().replace(" ","_") + '.json', 'x')
collecttotem.close()

collecttotem = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/collect' + nameList[counter].lower().replace(" ","_") + '.json', 'a')
collecttotem = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/collect' + nameList[i].lower().replace(" ","_") + '.json', 'w+')

# writes the varied meta to the file
collecttotem.writelines(['{\n',
' "__comment": "Made by the Totems+ Team",\n',
' "display": {\n',
' "title": {\n'])
collecttotem.write(' "text": "Collect ' + nameList[counter] + '",\n')
collecttotem.writelines([' "color": "gold",\n',
' "title": {\n',
' "text": "Collect ' + nameList[i] + '",\n',
' "color": "gold",\n',
' "bold": true\n',
' },\n',
' "description": {\n'])
collecttotem.write(' "text": "Collect ' + nameList[counter] + ' to add to your collection",\n')
collecttotem.writelines([' "color": "yellow"\n',
' "description": {\n',
' "text": "Collect ' + nameList[i] + ' to add to your collection",\n',
' "color": "yellow"\n',
' },\n',
' "icon": {\n',
' "item": "minecraft:totem_of_undying",\n'])
collecttotem.write(' "nbt": "{CustomModelData:' + str(910340 + counter) + '}"\n')
collecttotem.write(' "nbt": "{CustomModelData:' + str(910340 + i) + '}"\n')
collecttotem.writelines([' },\n',
' "frame": "task",\n',
' "show_toast": true,\n',
' "announce_to_chat": true,\n',
' "hidden": false\n',
' },\n',
' "criteria": {\n'])
collecttotem.write(' "Collect' + nameList[counter] + '": {\n')
collecttotem.writelines([' "trigger": "minecraft:inventory_changed",\n',
' "criteria": {\n',
' "Collect' + nameList[i] + '": {\n',
' "trigger": "minecraft:inventory_changed",\n',
' "conditions": {\n',
' "items": [\n',
' {\n',
' "item": "minecraft:totem_of_undying",\n'])
collecttotem.write(' "nbt": "{CustomModelData:' + str(910340 + counter) + '}"\n')
collecttotem.write(' "nbt": "{CustomModelData:' + str(910340 + i) + '}"\n')
collecttotem.writelines([' }\n',
' ]\n',
' }\n',
Expand All @@ -278,59 +238,47 @@ def ADV():
'}'])
collecttotem.close()

# increases the counter by 1
counter += 1

#####

# re-sets the counter to 0
counter = 0

# cycles throught the name list
while len(nameList) != counter + 1:
for i in range(len(nameList)):

# creates the use totem advancement
usetotem = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/use' + nameList[counter].lower().replace(" ","_") + '.json', 'x')
usetotem.close()

usetotem = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/use' + nameList[counter].lower().replace(" ","_") + '.json', 'a')

usetotem = open(worldLocation + '/datapacks/Totems+ CMD/data/totemsplus/advancements/use' + nameList[i].lower().replace(" ","_") + '.json', 'w+')

# writes the varied meta to the file
usetotem.writelines(['{\n',
' "__comment": "Made by the Totems+ Team",\n',
' "display": {\n',
' "title": {\n'])
usetotem.write(' "text": "Use ' + nameList[counter] + '",\n')
usetotem.writelines([' "color": "gold",\n',
' "title": {\n',
' "text": "Use ' + nameList[i] + '",\n',
' "color": "gold",\n',
' "bold": true\n',
' },\n',
' "description": {\n'])
usetotem.write(' "text": "Use ' + nameList[counter] + ' to cheat death",\n')
usetotem.writelines([' "color": "yellow"\n',
' "description": {\n',
' "text": "Use ' + nameList[i] + ' to cheat death",\n',
' "color": "yellow"\n',
' },\n',
' "icon": {\n',
' "item": "minecraft:totem_of_undying",\n'])
usetotem.write(' "nbt": "{CustomModelData:' + str(910340 + counter) + '}"\n')
usetotem.write(' "nbt": "{CustomModelData:' + str(910340 + i) + '}"\n')
usetotem.writelines([' },\n',
' "frame": "challenge",\n',
' "show_toast": true,\n',
' "announce_to_chat": true,\n',
' "hidden": false\n',
' },\n',
' "criteria": {\n'])
usetotem.write(' "Use' + nameList[counter] + '": {\n')
usetotem.writelines([' "trigger": "minecraft:used_totem",\n',
' "criteria": {\n',
' "Use' + nameList[i] + '": {\n',
' "trigger": "minecraft:used_totem",\n',
' "conditions": {\n',
' "item": {\n',
' "item": "minecraft:totem_of_undying",\n'])
usetotem.write(' "nbt": "{CustomModelData:' + str(910340 + counter) + '}"\n')
usetotem.write(' "nbt": "{CustomModelData:' + str(910340 + i) + '}"\n')
usetotem.writelines([' }\n',
' }\n',
' }\n',
' },\n',
' "parent": "totemsplus:useall"\n',
'}'])
usetotem.close()

# increases the counter by 1
counter += 1
usetotem.close()
Loading

0 comments on commit a17768e

Please sign in to comment.