2323 */
2424package dev .renoux .emotes .mixins ;
2525
26+ import dev .renoux .emotes .utils .EmoteProcessor ;
2627import dev .renoux .emotes .utils .EmoteUtil ;
2728import net .fabricmc .api .EnvType ;
2829import net .fabricmc .loader .api .FabricLoader ;
3940
4041import java .util .Optional ;
4142
42- import static dev .renoux .emotes .Emotes .LOGGER ;
43- import static dev .renoux .emotes .Emotes .metadata ;
44-
4543@ Mixin (TranslatableContents .class )
4644public abstract class TranslatableContentsMixin {
4745 @ Shadow public abstract String getKey ();
@@ -56,9 +54,9 @@ private String getOrDefault(Language instance, String key, String fallback) {
5654
5755 @ Redirect (method = "visit(Lnet/minecraft/network/chat/FormattedText$StyledContentConsumer;Lnet/minecraft/network/chat/Style;)Ljava/util/Optional;" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/network/chat/FormattedText;visit(Lnet/minecraft/network/chat/FormattedText$StyledContentConsumer;Lnet/minecraft/network/chat/Style;)Ljava/util/Optional;" ))
5856 private <T > Optional <T > visit (FormattedText instance , FormattedText .StyledContentConsumer <T > tStyledContentConsumer , Style style ) {
59- if (FabricLoader . getInstance ().getEnvironmentType () == EnvType . CLIENT ) {
60- if ( this . getKey ().startsWith ( "emotes." )) {
61- String [] splitEmote = instance . getString ().split ( ":" );
57+ if (this . getKey ().startsWith ( "emotes." ) ) {
58+ String [] splitEmote = instance . getString ().split ( ":" );
59+ if ( FabricLoader . getInstance ().getEnvironmentType () == EnvType . CLIENT ) {
6260 Integer codepoint = EmoteUtil .getInstance ().getCodepoint (splitEmote [0 ].replace ("emotes." , "" ));
6361 if (codepoint == null ) {
6462 // Fix from @Juloos
@@ -67,6 +65,8 @@ private <T> Optional<T> visit(FormattedText instance, FormattedText.StyledConten
6765 String emote = Character .toString (codepoint );
6866 FormattedText newInstance = FormattedText .of (emote );
6967 return newInstance .visit (tStyledContentConsumer , style .withFont (EmoteUtil .CUSTOM_IMAGE_FONT_IDENTIFIER ).withHoverEvent (new HoverEvent .ShowText (Component .literal (splitEmote [1 ]))));
68+ } else {
69+ return FormattedText .of (splitEmote [splitEmote .length - 1 ]).visit (tStyledContentConsumer , style );
7070 }
7171 }
7272 return instance .visit (tStyledContentConsumer , style );
0 commit comments