|
24 | 24 | package dev.renoux.emotes.mixins; |
25 | 25 |
|
26 | 26 | import dev.renoux.emotes.utils.EmoteUtil; |
| 27 | +import net.fabricmc.api.EnvType; |
| 28 | +import net.fabricmc.loader.api.FabricLoader; |
27 | 29 | import net.minecraft.locale.Language; |
28 | 30 | import net.minecraft.network.chat.Component; |
29 | 31 | import net.minecraft.network.chat.FormattedText; |
@@ -54,17 +56,19 @@ private String getOrDefault(Language instance, String key, String fallback) { |
54 | 56 |
|
55 | 57 | @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;")) |
56 | 58 | private <T> Optional<T> visit(FormattedText instance, FormattedText.StyledContentConsumer<T> tStyledContentConsumer, Style style) { |
57 | | - if (this.getKey().startsWith("emotes.")) { |
58 | | - LOGGER.info("{} : Visiting that '{}'", metadata.getName(), instance.getString()); |
59 | | - String[] splitEmote = instance.getString().split(":"); |
60 | | - Integer codepoint = EmoteUtil.getInstance().getCodepoint(splitEmote[0].replace("emotes.", "")); |
61 | | - if (codepoint == null) { |
62 | | - // Fix from @Juloos |
63 | | - return FormattedText.of(splitEmote[splitEmote.length - 1]).visit(tStyledContentConsumer, style); |
| 59 | + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { |
| 60 | + if (this.getKey().startsWith("emotes.")) { |
| 61 | + LOGGER.info("{} : Visiting that '{}'", metadata.getName(), instance.getString()); |
| 62 | + String[] splitEmote = instance.getString().split(":"); |
| 63 | + Integer codepoint = EmoteUtil.getInstance().getCodepoint(splitEmote[0].replace("emotes.", "")); |
| 64 | + if (codepoint == null) { |
| 65 | + // Fix from @Juloos |
| 66 | + return FormattedText.of(splitEmote[splitEmote.length - 1]).visit(tStyledContentConsumer, style); |
| 67 | + } |
| 68 | + String emote = Character.toString(codepoint); |
| 69 | + FormattedText newInstance = FormattedText.of(emote); |
| 70 | + return newInstance.visit(tStyledContentConsumer, style.withFont(EmoteUtil.CUSTOM_IMAGE_FONT_IDENTIFIER).withHoverEvent(new HoverEvent.ShowText(Component.literal(splitEmote[1])))); |
64 | 71 | } |
65 | | - String emote = Character.toString(codepoint); |
66 | | - FormattedText newInstance = FormattedText.of(emote); |
67 | | - return newInstance.visit(tStyledContentConsumer, style.withFont(EmoteUtil.CUSTOM_IMAGE_FONT_IDENTIFIER).withHoverEvent(new HoverEvent.ShowText(Component.literal(splitEmote[1])))); |
68 | 72 | } |
69 | 73 | return instance.visit(tStyledContentConsumer, style); |
70 | 74 | } |
|
0 commit comments