- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.nio.file.Files;
- import java.nio.file.StandardCopyOption;
- import javax.json.Json;
- import javax.json.JsonObject;
- public class AssetsExtractor {
- public static void main(String[] args) {
- File assetsRoot = new File("minecraft/assets"); // Path to `assets`
- String version = "1.13-af"; // Index version
- File root = new File("minecraft/extracted");
- File objects = new File(assetsRoot, "objects");
- File indexes = new File(assetsRoot, "indexes");
- try (InputStream in = new FileInputStream(new File(indexes, version + ".json"))) {
- JsonObject index = Json.createReader(in).readObject().getJsonObject("objects");
- for (String key : index.keySet()) {
- System.out.println("Copying " + key);
- String hash = index.getJsonObject(key).getString("hash");
- File file = new File(root, version + '/' + key);
- file.getParentFile().mkdirs();
- Files.copy(new File(objects, hash.substring(0, 2) + '/' + hash).toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
复制代码 |