Caxton incompatibility
vgskye opened this issue ยท 0 comments
As Caxton completely replaces vanilla text rendering when a piece of text is rendered via a Caxton font, any inlines in the text's not rendered.
Assuming that the inline renderer does not actually care about the font, this can be easily fixed by spoofing a bogus font id for the inline; a basic patch would be
diff --git a/common/src/main/java/com/samsthenerd/inline/mixin/core/MixinInlineStyle.java b/common/src/main/java/com/samsthenerd/inline/mixin/core/MixinInlineStyle.java
index 20c13b6..9141bd6 100644
--- a/common/src/main/java/com/samsthenerd/inline/mixin/core/MixinInlineStyle.java
+++ b/common/src/main/java/com/samsthenerd/inline/mixin/core/MixinInlineStyle.java
@@ -167,6 +167,14 @@ public class MixinInlineStyle implements InlineStyle {
return newStyle;
}
+ @ModifyReturnValue(method = "getFont", at = @At("RETURN"))
+ private Identifier overrideFont(Identifier original) {
+ if(this.getInlineData() != null){
+ return new Identifier("inline", "dummy_font");
+ }
+ return original;
+ }
+
@ModifyReturnValue(method = "withColor(Lnet/minecraft/text/TextColor;)Lnet/minecraft/text/Style;",
at=@At("RETURN"))
private Style fixWithColor(Style newStyle, TextColor color){
With the above patch applied, inlines are rendered properly with Caxton. Notably, the fact that the identified font doesn't actually exist doesn't seem to cause any issues.
(this probably applies to other font mods as well but Caxton is just the one I used)