File size: 2,424 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package net.minecraft.data;

import java.nio.file.Path;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;

public class PackOutput {
    private final Path outputFolder;

    public PackOutput(Path p_252039_) {
        this.outputFolder = p_252039_;
    }

    public Path getOutputFolder() {
        return this.outputFolder;
    }

    public Path getOutputFolder(PackOutput.Target p_251669_) {
        return this.getOutputFolder().resolve(p_251669_.directory);
    }

    public PackOutput.PathProvider createPathProvider(PackOutput.Target p_249479_, String p_251050_) {
        return new PackOutput.PathProvider(this, p_249479_, p_251050_);
    }

    public PackOutput.PathProvider createRegistryElementsPathProvider(ResourceKey<? extends Registry<?>> p_344086_) {
        return this.createPathProvider(PackOutput.Target.DATA_PACK, Registries.elementsDirPath(p_344086_));
    }

    public PackOutput.PathProvider createRegistryTagsPathProvider(ResourceKey<? extends Registry<?>> p_345128_) {
        return this.createPathProvider(PackOutput.Target.DATA_PACK, Registries.tagsDirPath(p_345128_));
    }

    public static class PathProvider {
        private final Path root;
        private final String kind;

        PathProvider(PackOutput p_249025_, PackOutput.Target p_251200_, String p_251982_) {
            this.root = p_249025_.getOutputFolder(p_251200_);
            this.kind = p_251982_;
        }

        public Path file(ResourceLocation p_250940_, String p_251208_) {
            return this.root.resolve(p_250940_.getNamespace()).resolve(this.kind).resolve(p_250940_.getPath() + "." + p_251208_);
        }

        public Path json(ResourceLocation p_251634_) {
            return this.root.resolve(p_251634_.getNamespace()).resolve(this.kind).resolve(p_251634_.getPath() + ".json");
        }

        public Path json(ResourceKey<?> p_376925_) {
            return this.root.resolve(p_376925_.location().getNamespace()).resolve(this.kind).resolve(p_376925_.location().getPath() + ".json");
        }
    }

    public static enum Target {
        DATA_PACK("data"),
        RESOURCE_PACK("assets"),
        REPORTS("reports");

        final String directory;

        private Target(final String p_251326_) {
            this.directory = p_251326_;
        }
    }
}