Skip to content

Instantly share code, notes, and snippets.

@damp11113
Last active April 20, 2023 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damp11113/edf6041a8d7ae88eb1bac2608ecd26e9 to your computer and use it in GitHub Desktop.
Save damp11113/edf6041a8d7ae88eb1bac2608ecd26e9 to your computer and use it in GitHub Desktop.
Minecraft Sounds Extractor python
import os
import json
import shutil
# ---------------- setting here --------------------
extracted_path = <extracted folder>
objects_path = <objects folder>
index_json = <index file ex 1.19.json>
# ---------------------------------------------------
data = json.load(open(index_json, 'r', encoding="utf-8"))["objects"]
objectspath = os.path.dirname(objects_path)
for key, value in data.items():
if str(key) == "minecraft/sounds.json": continue
if str(key).startswith('minecraft/sounds'):
hash = value['hash']
caf = str(key).split('minecraft/sounds/')[1]
for root, dirs, files in os.walk(objectspath):
for file in files:
if file == hash:
filename = caf.split('/')[-1]
cpath = caf.split(filename)[0]
shutil.copy(root + '/' + str(file), extracted_path)
if not os.path.exists(extracted_path + '/' + cpath):
os.makedirs(extracted_path + '/' + cpath)
os.rename(extracted_path + '/' + hash, extracted_path + '/' + cpath + filename)
print(root + '/' + str(file) + " ---> " + extracted_path + '/' + str(file) + " ---> " + extracted_path + "/" + cpath + filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment