Skip to content

Commit

Permalink
Update sound.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Hahaa13 committed Jun 10, 2024
1 parent 1e6abd9 commit dd9b34b
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
for file in files:
with open(file, "r") as f:
data = json.load(f)
namespace = file.split('\\')[1]
namespace = file.split(os.sep)[1]
names = [d for d in data]
with open("staging/target/rp/sounds/sound_definitions.json", "r") as f:
dj = json.load(f)
Expand All @@ -22,21 +22,18 @@
sounds = data[name]["sounds"]
listsound = []
for sound in sounds:
if True:#try:
if type(sound).__name__ == "dict":
sound["name"]
b = (sound["name"].split(":")[-1] + ".ogg").split((sound['name'].split(':')[-1] + ".ogg").split("/")[-1])[0]
sound["name"] = "sounds/" + sound["name"].split(":")[-1]
os.makedirs("staging/target/rp/sounds/" + b, exist_ok=True)
shutil.copyfile(f"pack/assets/minecraft/{sound['name'].split(':')[-1]}.ogg", f"staging/target/rp/{sound['name'].split(':')[-1]}.ogg")
listsound.append(sound)
else:
b = (sound.split(":")[-1] + ".ogg").split((sound.split(':')[-1] + ".ogg").split("/")[-1])[0]
os.makedirs("staging/target/rp/sounds/" + b, exist_ok=True)
shutil.copyfile(f"pack/assets/minecraft/sounds/{sound.split(':')[-1]}.ogg", f"staging/target/rp/sounds/{sound.split(':')[-1]}.ogg")
a = "sounds/" + sound.split(":")[-1]
listsound.append(a)
#except Exception as e:
#print(e)
if type(sound).__name__ == "dict":
sound["name"]
b = (sound["name"].split(":")[-1] + ".ogg").split((sound['name'].split(':')[-1] + ".ogg").split("/")[-1])[0]
sound["name"] = "sounds/" + sound["name"].split(":")[-1]
os.makedirs("staging/target/rp/sounds/" + b, exist_ok=True)
shutil.copyfile(f"pack/assets/minecraft/{sound['name'].split(':')[-1]}.ogg", f"staging/target/rp/{sound['name'].split(':')[-1]}.ogg")
listsound.append(sound)
else:
b = (sound.split(":")[-1] + ".ogg").split((sound.split(':')[-1] + ".ogg").split("/")[-1])[0]
os.makedirs("staging/target/rp/sounds/" + b, exist_ok=True)
shutil.copyfile(f"pack/assets/minecraft/sounds/{sound.split(':')[-1]}.ogg", f"staging/target/rp/sounds/{sound.split(':')[-1]}.ogg")
a = "sounds/" + sound.split(":")[-1]
listsound.append(a)
dj["sound_definitions"][f"{namespace}:{name}"]["sounds"] = listsound
json.dump(dj, f, indent=2)

0 comments on commit dd9b34b

Please sign in to comment.