Jump to content

[Solved] Repeated Messages


Recommended Posts

I am having an issue with my mod where there will be chat messages that repeat, though I can't seem to find it. There's no issue in single player, but on multiplayer, this happens:


This server has an anti-spam, where 2 messages in a row can't be the same, therefore it's repeating messages. However, I can't figure out where in the code it would do that (I'm probably missing something obvious).

[spoiler=Main]package com.wuble.chattranslate;


import com.wuble.chattranslate.handler.ChatHandler;

import com.wuble.chattranslate.handler.ConfigurationHandler;

import com.wuble.chattranslate.proxy.IProxy;

import com.wuble.chattranslate.reference.ClassReference;

import com.wuble.chattranslate.reference.NameReference;

import net.minecraftforge.common.MinecraftForge;

import net.minecraftforge.common.config.Configuration;

import net.minecraftforge.fml.common.FMLCommonHandler;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.SidedProxy;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import com.memetix.mst.translate.Translate;



@Mod(modid = NameReference.MODID, name = NameReference.MODNAME, version = NameReference.VERSION)

public class ChatTranslate {


    public static String langDefault, clientId, clientSecret;


    public static ChatTranslate instance;


    @SidedProxy(clientSide = ClassReference.CLIENT_PROXY_CLASS, serverSide =  ClassReference.SERVER_PROXY_CLASS)

    public static IProxy proxy;



    public static void preInit (FMLPreInitializationEvent event){


        FMLCommonHandler.instance().bus().register(new ConfigurationHandler());

        try{ initializeTranslate(); } catch (Exception e) {e.printStackTrace(); }

        MinecraftForge.EVENT_BUS.register(new ChatHandler());






    public static void init(FMLInitializationEvent event){





    public static void postInit(FMLPostInitializationEvent event){



    public static void initializeTranslate() throws Exception {








[spoiler=Thread]package com.wuble.chattranslate.thread;


import com.memetix.mst.detect.Detect;

import com.memetix.mst.language.Language;

import com.memetix.mst.translate.Translate;

import com.wuble.chattranslate.handler.ChatHandler;

import com.wuble.chattranslate.handler.ConfigurationHandler;

import net.minecraft.client.Minecraft;

import net.minecraft.util.ChatComponentText;

import net.minecraft.util.EnumChatFormatting;


public class TranslateThread extends Thread {

    public static String receivedMessage, receivedFormatted;

    private static Language from, langDefault;



    public void run(){

        receivedMessage = ChatHandler.receivedMessage;

        receivedFormatted = ChatHandler.receivedFormatted;

        langDefault = Language.fromString(ConfigurationHandler.langDefault);

        try {from = Detect.execute(receivedMessage);} catch(Exception e){e.printStackTrace();}

        if (from == langDefault){

            Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(receivedFormatted));


        else {

            try {Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(Translate.execute(receivedMessage,

                from, langDefault) + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + " [From: " + from.getName(langDefault) + "]" ).setChatStyle(ChatHandler.clickableChat)); } catch(Exception e) { e.printStackTrace(); }






[spoiler=ChatHandler]package com.wuble.chattranslate.handler;


import com.wuble.chattranslate.thread.TranslateThread;

import net.minecraft.event.HoverEvent;

import net.minecraft.util.ChatComponentText;

import net.minecraft.util.ChatStyle;

import net.minecraftforge.client.event.ClientChatReceivedEvent;

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;



public class ChatHandler {


  public static String receivedMessage, receivedFormatted;

    public static ChatStyle clickableChat;



    public void onClientChatReceived(ClientChatReceivedEvent event){

        receivedFormatted = event.message.getFormattedText();

        receivedMessage = event.message.getUnformattedText();

        HoverEvent chatHover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(receivedFormatted));

        clickableChat = new ChatStyle().setChatHoverEvent(chatHover);


        new TranslateThread().start();









This will break horribly, you cannot add chat messages from a different thread.

^^ This appears to have been the issue.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • forge doesn't download it says:  These libraries failed to download. Try again. com.google.code.findbugs;jsr305:3.0.2 commons-io:commons-io:2.4  
    • yeah so that worked and now I get these errors: Caused by: java.lang.reflect.InvocationTargetException Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered Caused by: org.spongepowered.asm.mixin.throwables.MixinApplyError: Mixin [create.mixins.json:CustomItemUseEffectsMixin] from phase [DEFAULT] in config [create.mixins.json] FAILED during APPLY Execution failed for task ':runClient'. > Process 'command 'C:\Users\Private\.jdks\corretto-17.0.5\bin\java.exe'' finished with non-zero exit value 1 * Try: > Run with --stacktrace option to get the stack trace. > Run with --scan to get full insights.   the build.gradle file now looks like this https://drive.google.com/file/d/1HodF_xeVLAvUuFI6EhXqTSPSIADAnv5o/view?usp=sharing I'm sorry if I'm wasting your time
    • He's actually got a  mistake in the video. It's relatively minor, though. But as far as accuracy, no one really tells you what to do to include biome modifications, configured/placed features, etc. You never get all the information in one place. Developers are the world's most ineffective documenters (I know because I am one) ...  This is what I've done so far... First using Data Pack Generators created a project and organized like mod directory structure. Second, I created a custom `configured_feature/disk_clay` and `placed_feature/disk_clay` for the `minecraft:river` biome to reference. But I have more planned changes to the river biome (and others). So, I copied minecraft `river.json`, place that in the `foundations/data/worldgen/biome/` directory. To have minecraft reference the biome, I overrode the default `minecraft/data/dimension/overworld.json`. Where ever I found `minecraft:river` in overworld.json, I replaced with `foundations:river`. The clay is still just minecraft:clay ... not foundations:clay. See screen shot. So, I don't know what is keeping my clay blocks from being in the feature. P.S. -- how come I can insert image links from imgur?
    • I am remaking an unofficial version of the VOLTZ modpack, however I am using mods from 1.19.2 to do so, and have just been going through curseforge and clicking add on everything I might want in the modpack. I think the problem has something to do with mixin, but I am not 100% sure on this, and I am not using anything like rubidium, or iris, or optifine to mess with shaders, so I am not sure where the problem is occuring from. Here is my Latest.log: https://pastebin.com/hF61MP5Y Here is my Debug.log: Part1: https://pastebin.com/mueThZ5E Part2: https://pastebin.com/J4RG46uK Part3: https://pastebin.com/B61pQueS Sorry for the parts, but the entire debug.log is almost an entire megabyte, and pastebin only allows 512kb maximum (issues splitting the file in two, so I split it in 3) I at least need a few magic mods, energy mods, and the Ballistix mod to be happy, CC:tweaked and it's two peripheral addons is preferred as well, but whatever is causing issues needs to go. One thing I keep seeing at the bottom of part 3 of the debug log, is this error: Class version 61 required is higher than the class version supported by the current version of Mixin (JAVA_8 supports class version 52)
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.