Posted June 21, 201510 yr Hello! I am currently developing a mod which will translate chat that is received to the chosen language (currently hard-coded to English). I am doing this with Microsoft translate. I've come across the issue that, upon receiving a chat message, the game will temporarily lag. If I'm correct, this is due to waiting to get the detect result for every message (Detect.execute). Would there be a way to fix this so that it doesn't lag the game? VIDEO: https://www.youtube.com/watch?v=vleaJqNftCE (Though it's short, it's visible that every received chat message lags the game.) [spoiler=Code] package com.wuble.chattranslate.handler; import com.memetix.mst.translate.Translate; import com.memetix.mst.detect.Detect; import com.memetix.mst.language.Language; import net.minecraft.util.*; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ChatHandler { public static String receivedMessage, sentMessage; public static Language from; @SubscribeEvent public void onClientChatReceived(ClientChatReceivedEvent event){ receivedMessage = event.message.getUnformattedText(); try {from = Detect.execute(receivedMessage); } catch (Exception e) { } if (from == Language.ENGLISH) { } else { try { sentMessage = Translate.execute(receivedMessage, from, Language.ENGLISH) + " §7§o[From: " + from.getName(Language.ENGLISH) + "§7§o]"; event.message = new ChatComponentText(sentMessage); } catch (Exception e) { } } } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.