Skip to content

Instantly share code, notes, and snippets.

@apacheli
Created July 6, 2022 19:47
Show Gist options
  • Save apacheli/2771435cac3bdb86429d0ea478d3ec77 to your computer and use it in GitHub Desktop.
Save apacheli/2771435cac3bdb86429d0ea478d3ec77 to your computer and use it in GitHub Desktop.
const APPDATA = Deno.env.get("APPDATA");
const index = await Deno.readTextFile(
`${APPDATA}/.minecraft/assets/indexes/1.19.json`,
);
const json = JSON.parse(index);
const directories = {};
const promises1 = [];
const promises2 = [];
for (const filename in json.objects) {
if (filename.substring(filename.length - 4) !== ".ogg") {
continue;
}
const hash = json.objects[filename].hash;
const index = hash.substring(0, 2);
const object = `${APPDATA}/.minecraft/assets/objects/${index}/${hash}`;
const directory = filename.substring(0, filename.lastIndexOf("/"));
(directories[directory] ??= []).push({ filename, object });
}
for (const directory in directories) {
promises1.push(Deno.mkdir(directory, { recursive: true }));
}
await Promise.all(promises1);
for (const directory in directories) {
for (const { filename, object } of directories[directory]) {
const p = Deno.readFile(object).then((x) => Deno.writeFile(filename, x));
promises2.push(p);
}
}
await Promise.all(promises2);
console.log("Done.");
@broman
Copy link

broman commented Aug 21, 2022

this sucks

@Izumemori
Copy link

@broman why are you mean :(

@broman
Copy link

broman commented Sep 9, 2023

proud Deno hater

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment