Skip to content

Commit 0c815a4

Browse files
committed
🚑 Don't execute visit on Servers
1 parent 4429568 commit 0c815a4

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Mod Properties
5-
mod_version = 1.2.3
5+
mod_version = 1.2.4
66
# Notes: when debugging, use rc's, so it would become: 0.X.X-rc.X
77
maven_group = dev.renoux
88
archives_base_name = emotes-1.21.5

src/main/java/dev/renoux/emotes/mixins/TranslatableContentsMixin.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
package dev.renoux.emotes.mixins;
2525

2626
import dev.renoux.emotes.utils.EmoteUtil;
27+
import net.fabricmc.api.EnvType;
28+
import net.fabricmc.loader.api.FabricLoader;
2729
import net.minecraft.locale.Language;
2830
import net.minecraft.network.chat.Component;
2931
import net.minecraft.network.chat.FormattedText;
@@ -54,17 +56,19 @@ private String getOrDefault(Language instance, String key, String fallback) {
5456

5557
@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;"))
5658
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]))));
6471
}
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]))));
6872
}
6973
return instance.visit(tStyledContentConsumer, style);
7074
}

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"id": "emotes",
44
"version": "${version}",
55

6-
"name": "Emotes Mod Client",
6+
"name": "Emotes Mod",
77
"description": "Mod to use Emotes",
88
"authors": [
99
"fantomitechno (aka Simon R)"

0 commit comments

Comments
 (0)