PackOutput .java

net.minecraft.data.PackOutput (class, 74 lines): members: createRegistryComponentPathProvider, createRegistryElementsPathProvider, createPathProvider.

net.minecraft.dataclass74 linescommon2.3 KB

API Surface (9)

Path getOutputFolder()
Path getOutputFolder(final PackOutput.Target target)
PackOutput.PathProvider createPathProvider(final PackOutput.Target target, final String kind)
PackOutput.PathProvider createRegistryElementsPathProvider(final ResourceKey<? extends Registry<?>> registryKey)
PackOutput.PathProvider createRegistryTagsPathProvider(final ResourceKey<? extends Registry<?>> registryKey)
PackOutput.PathProvider createRegistryComponentPathProvider(final ResourceKey<? extends Registry<?>> registryKey)
Path file(final Identifier element, final String extension)
Path json(final Identifier element)
Path json(final ResourceKey<?> element)

Fields & Constants (1)

outputFolder

String literals (3)

".json"
"assets"
"reports"

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PackOutput.java74 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.data;
2
3
import java.nio.file.Path;
4
import net.minecraft.core.Registry;
5
import net.minecraft.core.registries.Registries;
6
import net.minecraft.resources.Identifier;
7
import net.minecraft.resources.ResourceKey;
8
9
public class PackOutput {
10
	private final Path outputFolder;
11
12
	public PackOutput(final Path outputFolder) {
13
		this.outputFolder = outputFolder;
14
	}
15
16
	public Path getOutputFolder() {
17
		return this.outputFolder;
18
	}
19
20
	public Path getOutputFolder(final PackOutput.Target target) {
21
		return this.getOutputFolder().resolve(target.directory);
22
	}
23
24
	public PackOutput.PathProvider createPathProvider(final PackOutput.Target target, final String kind) {
25
		return new PackOutput.PathProvider(this, target, kind);
26
	}
27
28
	public PackOutput.PathProvider createRegistryElementsPathProvider(final ResourceKey<? extends Registry<?>> registryKey) {
29
		return this.createPathProvider(PackOutput.Target.DATA_PACK, Registries.elementsDirPath(registryKey));
30
	}
31
32
	public PackOutput.PathProvider createRegistryTagsPathProvider(final ResourceKey<? extends Registry<?>> registryKey) {
33
		return this.createPathProvider(PackOutput.Target.DATA_PACK, Registries.tagsDirPath(registryKey));
34
	}
35
36
	public PackOutput.PathProvider createRegistryComponentPathProvider(final ResourceKey<? extends Registry<?>> registryKey) {
37
		return this.createPathProvider(PackOutput.Target.REPORTS, Registries.componentsDirPath(registryKey));
38
	}
39
40
	public static class PathProvider {
41
		private final Path root;
42
		private final String kind;
43
44
		private PathProvider(final PackOutput output, final PackOutput.Target target, final String kind) {
45
			this.root = output.getOutputFolder(target);
46
			this.kind = kind;
47
		}
48
49
		public Path file(final Identifier element, final String extension) {
50
			return element.withPath(path -> this.kind + "/" + path + "." + extension).resolveAgainst(this.root);
51
		}
52
53
		public Path json(final Identifier element) {
54
			return element.withPath(path -> this.kind + "/" + path + ".json").resolveAgainst(this.root);
55
		}
56
57
		public Path json(final ResourceKey<?> element) {
58
			return this.json(element.identifier());
59
		}
60
	}
61
62
	public enum Target {
63
		DATA_PACK("data"),
64
		RESOURCE_PACK("assets"),
65
		REPORTS("reports");
66
67
		private final String directory;
68
69
		Target(final String directory) {
70
			this.directory = directory;
71
		}
72
	}
73
}
74

Decompiled Minecraft 26.3 source of PackOutput (net/minecraft/data/PackOutput.java) with Mojang official mappings, stored verbatim on the site.