PackMetadataSection .java

net.minecraft.server.packs.metadata.pack.PackMetadataSection (record): members: description, supportedFormats, FALLBACK_CODEC, FALLBACK_TYPE, CLIENT_TYPE.

net.minecraft.server.packs.metadata.packrecord37 linesserver1.8 KB

API Surface (2)

record PackMetadataSection(Component description, InclusiveRange<PackFormat> supportedFormats)
MetadataSectionType<PackMetadataSection> forPackType(final PackType packType)

Fields & Constants (4)

FALLBACK_CODEC
CLIENT_TYPE
SERVER_TYPE
FALLBACK_TYPE

String literals (2)

"description"
"pack"

Same Package (2)

Code Graph: Dependencies (6)

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

Full Source

PackMetadataSection.java37 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.packs.metadata.pack;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import net.minecraft.network.chat.Component;
6
import net.minecraft.network.chat.ComponentSerialization;
7
import net.minecraft.server.packs.PackType;
8
import net.minecraft.server.packs.metadata.MetadataSectionType;
9
import net.minecraft.util.InclusiveRange;
10
11
public record PackMetadataSection(Component description, InclusiveRange<PackFormat> supportedFormats) {
12
	private static final Codec<PackMetadataSection> FALLBACK_CODEC = RecordCodecBuilder.create(
13
		i -> i.group(ComponentSerialization.CODEC.fieldOf("description").forGetter(PackMetadataSection::description))
14
			.apply(i, description -> new PackMetadataSection(description, new InclusiveRange<>(PackFormat.of(Integer.MAX_VALUE))))
15
	);
16
	public static final MetadataSectionType<PackMetadataSection> CLIENT_TYPE = new MetadataSectionType<>("pack", codecForPackType(PackType.CLIENT_RESOURCES));
17
	public static final MetadataSectionType<PackMetadataSection> SERVER_TYPE = new MetadataSectionType<>("pack", codecForPackType(PackType.SERVER_DATA));
18
	public static final MetadataSectionType<PackMetadataSection> FALLBACK_TYPE = new MetadataSectionType<>("pack", FALLBACK_CODEC);
19
20
	private static Codec<PackMetadataSection> codecForPackType(final PackType packType) {
21
		return RecordCodecBuilder.create(
22
			i -> i.group(
23
					ComponentSerialization.CODEC.fieldOf("description").forGetter(PackMetadataSection::description),
24
					PackFormat.packCodec(packType).forGetter(PackMetadataSection::supportedFormats)
25
				)
26
				.apply(i, PackMetadataSection::new)
27
		);
28
	}
29
30
	public static MetadataSectionType<PackMetadataSection> forPackType(final PackType packType) {
31
		return switch (packType) {
32
			case CLIENT_RESOURCES -> CLIENT_TYPE;
33
			case SERVER_DATA -> SERVER_TYPE;
34
		};
35
	}
36
}
37

Decompiled Minecraft 26.3 source of PackMetadataSection (net/minecraft/server/packs/metadata/pack/PackMetadataSection.java) with Mojang official mappings, stored verbatim on the site.