def install_node_jar_extractor(): if not has_dir('minecraft-jar-extractor'): raise 'You need to run `git submodule init` and `git submodule update`' os.chdir('minecraft-jar-extractor') if not has_dir('node_modules'): os.system('npm install') os.chdir('..')
def run(versions=[], runBurger=True, runBE=True, runJarExtractor=True): install_node_jar_extractor() install_node_burger_extractor() utils.fetch_manifest() _vers = utils.extrapolate_versions(versions) if not has_dir("output/minecraft-data"): os.makedirs("output/minecraft-data") print("Extracting", versions, _vers) for version in _vers: if version in ('latest', 'snapshot', 'release'): version = utils.get_latest_version(version) print(c.BOLD, "Extracting", version, c.RESET) good = True if runBurger: good = good and run_burger(version) if runBE: good = good and run_burger_extractor(version) if runJarExtractor: good = good and run_prismarine_jar_extractor(version) if good: print(c.OKGREEN, f"{version} was successfully extracted", c.RESET) else: print(c.FAIL, f"{version} failed one or more extractions", c.RESET) pass
def run_prismarine_jar_extractor(version): # There could probably be a file in jar-extractor to do all of these steps dp = utils.get_decompiled_version(version) if not dp or not has_dir(dp + '/client'): print(version,dp) print(c.WARNING, f"Cannot run jar-extractor on {version} because you didn't decompile it. Run with --decompile.", c.RESET) return False os.chdir('minecraft-jar-extractor') print("Running minecraft-jar-extractor...") if utils.mc_version_cmp(version, '1.7') > 0: ## image name extractor a = f"node image_names.js {version} ../output/minecraft-assets ../{dp}/client" print(c.WARNING, '>', a, c.RESET) utils.journal_write('../output/minecraft-assets/*') os.system(a) b = f"node lang.js {version} ../output/minecraft-data ../{dp}/client" print(c.WARNING, '>', b, c.RESET) if utils.mc_version_cmp(version, '1.13') > 0: # 1.14+ # hacky stuff to make the script happy: move decompiled loot_tables # into data dir, js script then outputs to fake minecraft-data dir # which we copy over to our output dir. os.makedirs(f"data/{version}/data", exist_ok=True) os.makedirs(f"data/pc/{version}/", exist_ok=True) utils.move(f"../{dp}/client/data/minecraft/loot_tables", f"data/{version}/data/") a = f"node extract_lootTables.js {version} data ." print(c.WARNING, '>', a, c.RESET) os.system(a) # move data back utils.move(f"data/{version}/data/loot_tables", f"../{dp}/client/data/minecraft/") os.makedirs(f"../output/minecraft-data/{version}/", exist_ok=True) for filename in os.listdir(f"data/pc/{version}/*.json"): if filename.endswith('.json'): utils.journal_write(f"../output/minecraft-data/{version}/{filename}") utils.move(f"data/pc/{version}/*.json", f"../output/minecraft-data/{version}/") os.chdir('..') return True
def gen_diffs(ver1=None, ver2=None): utils.fetch_manifest() if ver1 and ver2: print(c.BOLD, "Diffing ", ver1, ver2, c.RESET) else: print(c.BOLD, "Diffing all versions", c.RESET) if not utils.has_dir('DecompilerMC/src/'): print("Not decompiled yet, run again with --decompile") return False os.makedirs('diffs', exist_ok=True) os.chdir('DecompilerMC/src/') mcp = [] mojang = [] for d in os.listdir('.'): if d.endswith('_mcp'): mcp.append(d.replace('_mcp', '')) elif d.endswith('_mojang'): mojang.append(d.replace('_mojang', '')) else: continue mcp = sorted(mcp, key=utils.get_date_for_version) mojang = sorted(mojang, key=utils.get_date_for_version) if ver1 and ver2: found = False if ver1 in mcp and ver2 in mcp: _gen_diffs(ver1, ver2, 'mcp') found = True if ver1 in mojang and ver2 in mojang: _gen_diffs(ver1, ver2, 'mojang') found = True if not found: print( utils.c.FAIL, f"Couldn't diff {ver1} and {ver2} because you haven't decompiled them. Run again with --decompile.", utils.c.RESET) # print("MCP Sorted: ", mcp) # print("Mojang sorted: ", mojang) return False else: mcp_pairs = make_pairs(mcp) moj_pairs = make_pairs(mojang) for pair in mcp_pairs: _gen_diffs(pair[0], pair[1], 'mcp') for pair in moj_pairs: _gen_diffs(pair[0], pair[1], 'mojang') print(c.OKGREEN, f"Successfully diff'ed. See diffs/", c.RESET) print("moving temp diffs to diffs/") for name in os.listdir('.'): if name.endswith('.diff'): try: os.remove(f"../../diffs/{name}") except Exception: pass utils.move(name, f"../../diffs/{name}") os.chdir('..') return True
def install_burger(): if not has_dir('Burger'): raise 'You need to run `git submodule init` and `git submodule update`'
def already_decompiled(version, client=True): s = 'client' if client else 'server' return has_dir(f'DecompilerMC/src/{version}/{s}') or has_dir( f'DecompilerMC/src/{version}_mcp/{s}') or has_dir( f'DecompilerMC/src/{version}_mojang/{s}')
def install_minecraft_decompiler(): if not has_dir('DecompilerMC'): raise 'You need to run `git submodule init` and `git submodule update`'