#printing messages I send to chat

25 messages · Page 1 of 1 (latest)

north pollen
#

so my current code is as follows

import static com.mojang.text2speech.Narrator.LOGGER;
@Mixin(ClientPlayerEntity.class)
public class ChatMixin {
    @Inject(at=@At("HEAD"), method="sendMessage(Lnet/minecraft/text/Text;)V")
    public void sendMessage(Text message, CallbackInfo ci){
        LOGGER.info(message.toString());
    }
}

but when I run it, it doesnt work. ive already added the mixin to the json and tried to just use system.out too, no output for either

rancid juniper
#

Why are you using the Narrator's logger?
What about it doesn't work? Have you breakpointed to make sure it runs? There's also probably an event for when you send a message.

north pollen
#

changed the code to just use println instead

@Mixin(ClientPlayerEntity.class)
public class ChatMixin {
    @Inject(at = @At("HEAD"), method = "sendMessage(Lnet/minecraft/text/Text;)V", cancellable = true)
    public void sendMessage(Text message, CallbackInfo ci){
        System.out.println(message);
    }
}

and should I breakpoint at mixin?

rancid juniper
#

Yep

north pollen
#

then for idea im guessing I just make the breakpoint on that line then run debug?

rancid juniper
#

Yep

north pollen
#

this is what shows up

rancid juniper
#

You breakpointed an annotation, not a method. Have you used a debugger before, or are you new to it?

north pollen
#

not for my own code

#

so would do it at the creation of the class ChatMixin?

rancid juniper
#

No, you'd do it either on the method or on the println call. If you want, go ahead and search for "debugging with IntelliJ" or "debugging basics" to learn more about how to use it.

north pollen
#

alright, and just for more info on the problem cuz I realize I didnt state it
my goal is to get the message the client sends before it actually gets sent, later on I want to save said message and stop it from being sent to the server

#

right now I just wanna inject into that method but it doesnt print out the message

rancid juniper
#

!!tut mixin_export

warped cargoBOT
rancid juniper
#

I'd check that out and see if the mixin is applying

north pollen
#

and when it says vm options, is it refering to build.gradle or would there be some setting for the compiler in the IDE

#

oh no I see

#

yea so I dont see my mixin anywhere in the client networking

#

which id assume is where it should be as it is a client networking class

#

something else I tried was putting the mixin under "client" instead of "mixins" and it still doesnt work

north pollen
#

update, the mixin now applies but the code just doesnt work

#

current code

package hippo.paradox.mixin;

import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.text.Text;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import hippo.paradox.Paradox;


@Mixin(ClientPlayerEntity.class)
public class ChatMixin {
    @Inject(at = @At("HEAD"), method = "sendMessage(Lnet/minecraft/text/Text;)V")
    public void sendMessage(Text message, CallbackInfo ci){
        Paradox.LOGGER.info(">> \"{}\" << :D", message.toString());
    }
}
#

current change

public void sendMessage(Text message) {
        this.handler$zem000$paradox$sendMessage(message, (CallbackInfo)null);
        this.client.inGameHud.getChatHud().addMessage(message);
}
rancid juniper
#

Are you sure sendMessage is called where you think it is?