Update to 1.19.3
This commit is contained in:
parent
c3d91d61b3
commit
0e2b1f034d
|
@ -15,5 +15,5 @@ dependencies {
|
||||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-reflect-v1:${prop("libjf_version")}")
|
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-reflect-v1:${prop("libjf_version")}")
|
||||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${prop("libjf_version")}")
|
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${prop("libjf_version")}")
|
||||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}")
|
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}")
|
||||||
modLocalRuntime("com.terraformersmc:modmenu:4.1.1")
|
modLocalRuntime("com.terraformersmc:modmenu:5.0.1")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# https://fabricmc.net/develop/
|
# https://fabricmc.net/develop/
|
||||||
minecraft_version=1.19.2
|
minecraft_version=1.19.3
|
||||||
yarn_mappings=build.24
|
yarn_mappings=build.2
|
||||||
loader_version=0.14.11
|
loader_version=0.14.11
|
||||||
|
|
||||||
maven_group=io.gitlab.jfronny
|
maven_group=io.gitlab.jfronny
|
||||||
|
@ -13,5 +13,5 @@ curseforge_id=574331
|
||||||
curseforge_required_dependencies=libjf
|
curseforge_required_dependencies=libjf
|
||||||
curseforge_optional_dependencies=modmenu
|
curseforge_optional_dependencies=modmenu
|
||||||
|
|
||||||
libjf_version=3.2.1
|
libjf_version=3.3.1
|
||||||
fabric_version=0.68.0+1.19.2
|
fabric_version=0.68.1+1.19.3
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package io.gitlab.jfronny.googlechat.mixin;
|
package io.gitlab.jfronny.googlechat.mixin;
|
||||||
|
|
||||||
import io.gitlab.jfronny.googlechat.*;
|
import io.gitlab.jfronny.googlechat.*;
|
||||||
|
import io.gitlab.jfronny.libjf.LibJf;
|
||||||
import net.minecraft.client.gui.screen.*;
|
import net.minecraft.client.gui.screen.*;
|
||||||
import org.spongepowered.asm.mixin.*;
|
import org.spongepowered.asm.mixin.*;
|
||||||
import org.spongepowered.asm.mixin.injection.*;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
|
|
||||||
@Mixin(ChatScreen.class)
|
@Mixin(ChatScreen.class)
|
||||||
public class ChatScreenMixin {
|
public class ChatScreenMixin {
|
||||||
@ModifyVariable(method = "tryRequestChatPreview(Ljava/lang/String;)V", at = @At(value = "HEAD"), argsOnly = true, ordinal = 0)
|
@ModifyVariable(method = "sendMessage(Ljava/lang/String;Z)Z", at = @At(value = "HEAD"), argsOnly = true, ordinal = 0)
|
||||||
String googlechat$translateChatText(String source) {
|
String googlechat$translateChatText(String chatText) {
|
||||||
return GoogleChat.translateIfNeeded(source, GoogleChat.Direction.C2S, true);
|
return GoogleChat.translateIfNeeded(chatText, GoogleChat.Direction.C2S, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package io.gitlab.jfronny.googlechat.mixin;
|
package io.gitlab.jfronny.googlechat.mixin;
|
||||||
|
|
||||||
import io.gitlab.jfronny.googlechat.*;
|
import io.gitlab.jfronny.googlechat.GoogleChat;
|
||||||
import net.minecraft.client.network.*;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import org.spongepowered.asm.mixin.*;
|
import net.minecraft.text.Text;
|
||||||
import org.spongepowered.asm.mixin.injection.*;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
|
||||||
@Mixin(ClientPlayerEntity.class)
|
@Mixin(ClientPlayerEntity.class)
|
||||||
public class ClientPlayerEntityMixin {
|
public class ClientPlayerEntityMixin {
|
||||||
@ModifyVariable(method = "sendChatMessage(Ljava/lang/String;Lnet/minecraft/text/Text;)V", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
@ModifyVariable(method = "sendMessage(Lnet/minecraft/text/Text;)V", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
String googlechat$translateMessage(String source) {
|
Text googlechat$translateMessage(Text source) {
|
||||||
return GoogleChat.translateIfNeeded(source, GoogleChat.Direction.C2S, true);
|
return GoogleChat.translateIfNeeded(source, GoogleChat.Direction.C2S, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,43 @@
|
||||||
package io.gitlab.jfronny.googlechat.mixin;
|
package io.gitlab.jfronny.googlechat.mixin;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import io.gitlab.jfronny.googlechat.GoogleChat;
|
import io.gitlab.jfronny.googlechat.GoogleChat;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.hud.ChatHud;
|
|
||||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
|
||||||
import net.minecraft.client.network.PlayerListEntry;
|
|
||||||
import net.minecraft.client.network.message.MessageHandler;
|
import net.minecraft.client.network.message.MessageHandler;
|
||||||
import net.minecraft.network.message.*;
|
import net.minecraft.network.message.MessageType;
|
||||||
|
import net.minecraft.network.message.SignedMessage;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.*;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
@Mixin(MessageHandler.class)
|
@Mixin(MessageHandler.class)
|
||||||
public class MessageHandlerMixin {
|
public class MessageHandlerMixin {
|
||||||
@Redirect(method = "processChatMessageInternal(Lnet/minecraft/network/message/MessageType$Parameters;Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/text/Text;Lnet/minecraft/client/network/PlayerListEntry;ZLjava/time/Instant;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V"))
|
@Redirect(method = "onChatMessage(Lnet/minecraft/network/message/SignedMessage;Lcom/mojang/authlib/GameProfile;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/message/MessageType$Parameters;applyChatDecoration(Lnet/minecraft/text/Text;)Lnet/minecraft/text/Text;"))
|
||||||
void googlechat$injectAddMessage(ChatHud instance, Text message, @Nullable MessageSignatureData signature, @Nullable MessageIndicator indicator, MessageType.Parameters args$params, SignedMessage args$message, Text args$decorated, @Nullable PlayerListEntry args$senderEntry, boolean args$onlyShowSecureChat, Instant args$receptionTimestamp) {
|
Text googlechat$applyDecoration(MessageType.Parameters instance, Text content, SignedMessage args$signed, GameProfile args$sender) {
|
||||||
MinecraftClient mc = MinecraftClient.getInstance();
|
return instance.applyChatDecoration(googlechat$shouldTranslate(args$sender) ? googlechat$translate(content) : content);
|
||||||
if (mc != null && mc.player != null && args$senderEntry != null && !args$senderEntry.getProfile().getId().equals(mc.player.getUuid()))
|
|
||||||
message = googlechat$translate(message);
|
|
||||||
instance.addMessage(message, signature, indicator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "processProfilelessMessage(Lnet/minecraft/network/message/MessageType$Parameters;Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/text/Text;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;)V"))
|
@Redirect(method = "processChatMessageInternal(Lnet/minecraft/network/message/MessageType$Parameters;Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/text/Text;Lcom/mojang/authlib/GameProfile;ZLjava/time/Instant;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/message/MessageType$Parameters;applyChatDecoration(Lnet/minecraft/text/Text;)Lnet/minecraft/text/Text;"))
|
||||||
void googlechat$injectAddMessage(ChatHud instance, Text message) {
|
Text googlechat$applyDecoration2(MessageType.Parameters instance, Text content, MessageType.Parameters args$params, SignedMessage args$message, Text args$decorated, GameProfile args$sender) {
|
||||||
instance.addMessage(googlechat$translate(message));
|
return instance.applyChatDecoration(googlechat$shouldTranslate(args$sender) ? googlechat$translate(content) : content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyVariable(method = "onProfilelessMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At(value = "HEAD"), argsOnly = true, ordinal = 0)
|
||||||
|
Text googlechat$applyTranslation(Text origin) {
|
||||||
|
return googlechat$translate(origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyVariable(method = "onGameMessage(Lnet/minecraft/text/Text;Z)V", at = @At(value = "HEAD"), argsOnly = true, ordinal = 0)
|
||||||
|
Text googlechat$applyTranslation2(Text origin) {
|
||||||
|
return googlechat$translate(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Text googlechat$translate(Text message) {
|
private Text googlechat$translate(Text message) {
|
||||||
return GoogleChat.translateIfNeeded(message, GoogleChat.Direction.S2C, true);
|
return GoogleChat.translateIfNeeded(message, GoogleChat.Direction.S2C, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean googlechat$shouldTranslate(GameProfile sender) {
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
return mc != null && mc.player != null && sender != null && !sender.getId().equals(mc.player.getUuid());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class GoogleChat implements ModInitializer {
|
||||||
return source;
|
return source;
|
||||||
if (GoogleChatConfig.desugar) {
|
if (GoogleChatConfig.desugar) {
|
||||||
MutableText translatedText = Text.literal(translateIfNeeded(sourceString, direction, true));
|
MutableText translatedText = Text.literal(translateIfNeeded(sourceString, direction, true));
|
||||||
|
if (GoogleChatConfig.debugLogs) LOGGER.info("Translated " + sourceString + " to " + toString(translatedText));
|
||||||
if (GoogleChatConfig.translationTooltip)
|
if (GoogleChatConfig.translationTooltip)
|
||||||
return source.copy().setStyle(addHover(Style.EMPTY, Text.literal("Translated: ").append(translatedText)));
|
return source.copy().setStyle(addHover(Style.EMPTY, Text.literal("Translated: ").append(translatedText)));
|
||||||
else
|
else
|
||||||
|
@ -110,7 +111,7 @@ public class GoogleChat implements ModInitializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasTarget(Direction direction) {
|
private static boolean hasTarget(Direction direction) {
|
||||||
return TRANSLATE_SERVICE.parseLang(switch (direction) {
|
return !TRANSLATE_SERVICE.parseLang(switch (direction) {
|
||||||
case C2S -> GoogleChatConfig.serverLanguage;
|
case C2S -> GoogleChatConfig.serverLanguage;
|
||||||
case S2C -> GoogleChatConfig.clientLanguage;
|
case S2C -> GoogleChatConfig.clientLanguage;
|
||||||
}).getIdentifier().equals("auto");
|
}).getIdentifier().equals("auto");
|
||||||
|
|
|
@ -44,8 +44,9 @@ public class GoogleChatConfig {
|
||||||
@Verifier
|
@Verifier
|
||||||
public static void verify() {
|
public static void verify() {
|
||||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER && !clientLanguage.equals("auto")) {
|
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER && !clientLanguage.equals("auto")) {
|
||||||
System.err.println("Your client language is not set to \"auto\" and you are using a server.\n"
|
System.err.println("""
|
||||||
+ "This setup is not recommended! Please set up GoogleChat according to its documentation!");
|
Your client language is not set to "auto" and you are using a server.
|
||||||
|
This setup is not recommended! Please set up GoogleChat according to its documentation!""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
"google-chat.jfconfig.sendingRegex.tooltip": "A Regex pattern to check whether a sent message should be translated",
|
"google-chat.jfconfig.sendingRegex.tooltip": "A Regex pattern to check whether a sent message should be translated",
|
||||||
"google-chat.jfconfig.sendingRegexIsBlacklist": "Sending Regex Is Blacklist",
|
"google-chat.jfconfig.sendingRegexIsBlacklist": "Sending Regex Is Blacklist",
|
||||||
"google-chat.jfconfig.sendingRegexIsBlacklist.tooltip": "Whether the relevant regex should blacklist messages from translation instead of whitelisting",
|
"google-chat.jfconfig.sendingRegexIsBlacklist.tooltip": "Whether the relevant regex should blacklist messages from translation instead of whitelisting",
|
||||||
|
"google-chat.jfconfig.debugLogs": "Debug Logs",
|
||||||
|
"google-chat.jfconfig.debugLogs.tooltips": "Log additional information about message processing. Useful for debugging",
|
||||||
|
|
||||||
"google-chat.jfconfig.client": "Client",
|
"google-chat.jfconfig.client": "Client",
|
||||||
"google-chat.jfconfig.server": "Server"
|
"google-chat.jfconfig.server": "Server"
|
||||||
|
|
Loading…
Reference in New Issue