How to replace one message to other in minecraft fabric 1.21.5 I writed simple Mixin that insert code into writen method
package org.emil.chatmod.mixin; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Objects; import java.util.Optional; @Mixin(ClientPlayNetworkHandler.class) public abstract class ClientPlayNetworkHandlerMixin { @Shadow public abstract void sendChatMessage(String content); @Inject(method = "sendChatMessage", at = @At("HEAD")) private void onsendChatMessage(String message, CallbackInfo ci) { if (message.contains("foo")){ this.sendChatMessage("bar"); } } } But when the message contains foo I want to send "bar" to Server, but when I execute sendChatMessage there is a loop going on and minecraft crashes