package net.minecraft.network.chat.numbers; import com.mojang.serialization.MapCodec; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.ComponentSerialization; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.codec.StreamCodec; public class FixedFormat implements NumberFormat { public static final NumberFormatType TYPE = new NumberFormatType() { private static final MapCodec CODEC = ComponentSerialization.CODEC.fieldOf("value").xmap(FixedFormat::new, fixedFormat -> fixedFormat.value); private static final StreamCodec STREAM_CODEC = StreamCodec.composite( ComponentSerialization.TRUSTED_STREAM_CODEC, fixedFormat -> fixedFormat.value, FixedFormat::new ); @Override public MapCodec mapCodec() { return CODEC; } @Override public StreamCodec streamCodec() { return STREAM_CODEC; } }; final Component value; public FixedFormat(Component value) { this.value = value; } @Override public MutableComponent format(int number) { return this.value.copy(); } @Override public NumberFormatType type() { return TYPE; } }