MetadataSectionType .java

net.minecraft.server.packs.metadata.MetadataSectionType (record, 17 lines): members: WithValue, withValue, name, codec. imports: Codec.

net.minecraft.server.packs.metadatarecord17 linesserver538 B

API Surface (2)

MetadataSectionType.WithValue<T> withValue(final T value)
<U> Optional<U> unwrapToType(final MetadataSectionType<U> type)

Same Package (1)

Full Source

MetadataSectionType.java17 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.packs.metadata;
2
3
import com.mojang.serialization.Codec;
4
import java.util.Optional;
5
6
public record MetadataSectionType<T>(String name, Codec<T> codec) {
7
	public MetadataSectionType.WithValue<T> withValue(final T value) {
8
		return new MetadataSectionType.WithValue<>(this, value);
9
	}
10
11
	public record WithValue<T>(MetadataSectionType<T> type, T value) {
12
		public <U> Optional<U> unwrapToType(final MetadataSectionType<U> type) {
13
			return type == this.type ? Optional.of(this.value) : Optional.empty();
14
		}
15
	}
16
}
17

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