FixedFormat .java

net.minecraft.network.chat.numbers.FixedFormat (record, 38 lines): members: value, format, TYPE, type. imports: MutableComponent, ComponentSerialization.

net.minecraft.network.chat.numbersrecord38 linescommon1.2 KB

Implements

API Surface (4)

MapCodec<FixedFormat> mapCodec()
StreamCodec<RegistryFriendlyByteBuf, FixedFormat> streamCodec()
MutableComponent format(final int value)
NumberFormatType<FixedFormat> type()

Fields & Constants (1)

TYPE

Code Graph: Dependencies (7)

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

Full Source

FixedFormat.java38 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.chat.numbers;
2
3
import com.mojang.serialization.MapCodec;
4
import net.minecraft.network.RegistryFriendlyByteBuf;
5
import net.minecraft.network.chat.Component;
6
import net.minecraft.network.chat.ComponentSerialization;
7
import net.minecraft.network.chat.MutableComponent;
8
import net.minecraft.network.codec.StreamCodec;
9
10
public record FixedFormat(Component value) implements NumberFormat {
11
	public static final NumberFormatType<FixedFormat> TYPE = new NumberFormatType<FixedFormat>() {
12
		private static final MapCodec<FixedFormat> CODEC = ComponentSerialization.CODEC.fieldOf("value").xmap(FixedFormat::new, FixedFormat::value);
13
		private static final StreamCodec<RegistryFriendlyByteBuf, FixedFormat> STREAM_CODEC = StreamCodec.composite(
14
			ComponentSerialization.TRUSTED_STREAM_CODEC, FixedFormat::value, FixedFormat::new
15
		);
16
17
		@Override
18
		public MapCodec<FixedFormat> mapCodec() {
19
			return CODEC;
20
		}
21
22
		@Override
23
		public StreamCodec<RegistryFriendlyByteBuf, FixedFormat> streamCodec() {
24
			return STREAM_CODEC;
25
		}
26
	};
27
28
	@Override
29
	public MutableComponent format(final int value) {
30
		return this.value.copy();
31
	}
32
33
	@Override
34
	public NumberFormatType<FixedFormat> type() {
35
		return TYPE;
36
	}
37
}
38

Decompiled Minecraft 26.3 source of FixedFormat (net/minecraft/network/chat/numbers/FixedFormat.java) with Mojang official mappings, stored verbatim on the site.