2022-06-07 21:34:26 +02:00
|
|
|
package io.gitlab.jfronny.googlechat.mixin;
|
|
|
|
|
2023-02-15 20:32:19 +01:00
|
|
|
import io.gitlab.jfronny.googlechat.GoogleChat;
|
|
|
|
import net.minecraft.client.gui.screen.ChatScreen;
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
2022-06-07 21:34:26 +02:00
|
|
|
|
|
|
|
@Mixin(ChatScreen.class)
|
|
|
|
public class ChatScreenMixin {
|
2022-12-08 18:06:28 +01:00
|
|
|
@ModifyVariable(method = "sendMessage(Ljava/lang/String;Z)Z", at = @At(value = "HEAD"), argsOnly = true, ordinal = 0)
|
|
|
|
String googlechat$translateChatText(String chatText) {
|
2023-02-15 20:32:19 +01:00
|
|
|
if (chatText.startsWith("/")) return chatText; // Bypass for client-side commands (Carpet, ...)
|
2022-12-08 18:06:28 +01:00
|
|
|
return GoogleChat.translateIfNeeded(chatText, GoogleChat.Direction.C2S, true);
|
2022-06-07 21:34:26 +02:00
|
|
|
}
|
|
|
|
}
|