#Trying to mixin to ClientPacketListener

43 messages · Page 1 of 1 (latest)

nova spear
#

hello - beginnner problem
posted earlier and got a solution that ended up not working. i can find net.minecraft.client.multiplayer.ClientPacketListener in my decompiled 1.20.4 code, but when i try to import it to a mixin class it can't find it. Advice/solutions?

daring lily
#

That is for Minecraft and the packets the vanilla game listens to. If you are trying to send your own packets between the client and server, what you want to be looking at is ClientPlayNetworking and ServerPlayNetworking from FAPI. This allows you to register and listen to your own packets

nova spear
#

i'm looking to intercept ClientboundSystemChatPacket s

#

and process them before the game does things with them

daring lily
#

Ah, makes sense now.

#

Let me take a quick look at the code

nova spear
#

thx <3

daring lily
#

Hmm, I can't find anything named ClientBoundSystemChatPacket. Is that the correct name for the class or are you using Mojmap for mappings?

karmic swallow
#

I found in Mojmaps ClientboundSystemChatPacket

daring lily
#

I guess that would be ChatMessageS2CPacket in yarn?

karmic swallow
#

In yarn it's GameMessage

daring lily
#

Ah, ok

karmic swallow
#

GameMessageS2CPacket

daring lily
#

My guess, and correct me if I am wrong Sky, would Fred want to mixin where this data is being set on the client (I don't remember what class it's done in)

#

ClientPlayNetworkHandler#onGameMessage, yarn mapping?

nova spear
#

uhhhhh ill look

#

im using the mappings you can find on the mc wiki

#

are there seperate ones for fabric?

daring lily
#

Probably would be better to do it in MessageHandler#onGameMessage because that is where the actual logic is taking place. And ClientPlayNetworkHandler#onGameMessage calls that, yarn mappings

daring lily
nova spear
#

k

#

ty much love

nova spear
daring lily
#

Can you post your mixin class?

nova spear
#

import net.minecraft.client.network.message.MessageHandler;
import net.minecraft.text.Text;
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;

@Mixin(MessageHandler.class)
public class PacketReaderMixin {

    @Inject(method = "onGameMessage", at = @At("HEAD"))
    private void init(Text message, boolean overlay, CallbackInfo ci) {
        System.out.println("test");
    }
}```
daring lily
#

And the stacktrace of the error?

#

Are you using Yarn mappings?

nova spear
#

yes

daring lily
#

Hmm

#

Are you using split sources?

#

My guess would be no you are not because you are experiencing this error.

nova spear
#

idk

daring lily
#

Make sure you have this in your build.gradle:

loom {
    splitEnvironmentSourceSets()

    mods {
        "your-modid" {
            sourceSet sourceSets.main
            sourceSet sourceSets.client
        }
    }

}
nova spear
#

yes

daring lily
#

And your code is in src/client/...?

nova spear
#

no its in src/main

#

ahhh i see

#

the main cant see client only shit

daring lily
#

pretty much 🙂

nova spear
#

i failed the idiot proofing