Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick script to extract/deobfuscate Minecraft assets folder
#!/usr/bin/env python3
import json, os, shutil, sys
if len(sys.argv) < 4 or sys.argv[1] == "--help" or sys.argv[1] == "-h":
print("Usage: " + sys.argv[0] + " <path to .minecraft/assets> <major.minor version, ex. 1.15> <output directory>")
sys.exit(1)
fp = open(sys.argv[1] + "/indexes/" + sys.argv[2] + ".json", "r")
if fp == None: raise FileNotFoundError("Could not find index file at " + sys.argv[1] + "/indexes/" + sys.argv[2] + ".json")
index = json.load(fp)
fp.close()
def recursive_mkdir(path):
if not os.path.isdir(os.path.dirname(path)) and os.path.dirname(path) != "": recursive_mkdir(os.path.dirname(path))
if not os.path.isdir(path): os.mkdir(path, 0o777)
for name, obj in index["objects"].items():
recursive_mkdir(sys.argv[3] + "/" + os.path.dirname(name))
shutil.copyfile(sys.argv[1] + "/objects/" + obj["hash"][:2] + "/" + obj["hash"], sys.argv[3] + "/" + name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment