public record Constant(int value) implements ItemTintSource {
16
public static final MapCodec<Constant> MAP_CODEC = RecordCodecBuilder.mapCodec(
17
i -> i.group(ExtraCodecs.RGB_COLOR_CODEC.fieldOf("value").forGetter(Constant::value)).apply(i, Constant::new)
18
);
19
20
public Constant {
21
value = ARGB.opaque(value);
22
}
23
24
@Override
25
public int calculate(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable LivingEntity owner) {
26
return this.value;
27
}
28
29
@Override
30
public MapCodec<Constant> type() {
31
return MAP_CODEC;
32
}
33
}
34
Decompiled Minecraft 26.3 source of Constant (net/minecraft/client/color/item/Constant.java) with Mojang official mappings, stored verbatim on the site.