I added a custom tint source, but not sure how to register it.
Here is the code for my custom tint source record
public record SlimeItemTint(int defaultColor) implements TintSource {
public static final MapCodec<SlimeItemTint> MAP_CODEC = RecordCodecBuilder.mapCodec(slimeItemTintInstance ->
slimeItemTintInstance.group(
Codecs.ARGB.fieldOf("default").forGetter(SlimeItemTint::defaultColor)
).apply(slimeItemTintInstance, SlimeItemTint::new)
);
@Override
public int getTint(ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity user) {
if (stack.contains(ModDataComponents.SLIME_DATA)) {
return ColorHelper.fullAlpha(stack.get(ModDataComponents.SLIME_DATA).color());
}
return defaultColor;
}
@Override
public MapCodec<? extends TintSource> getCodec() {
return MAP_CODEC;
}
}
And here is the error when i run datagen with my tint source
Caused by: java.lang.IllegalStateException: Element with unknown id: RecordCodec[UnitDecoder[com.chesy.productiveslimes.util.SlimeItemTint$$Lambda/0x000001eb84dead50@341fa52] * Field[default: EitherCodec[first=Int, second=ListCodec[Float][comapFlatMapped]][xmapped]]]; Element with unknown id: RecordCodec[UnitDecoder[com.chesy.productiveslimes.util.SlimeItemTint$$Lambda/0x000001eb84dead50@341fa52] * Field[default: EitherCodec[first=Int, second=ListCodec[Float][comapFlatMapped]][xmapped]]]