#Can't read Server Chat, just Singleplayer chat using Mixins

3 messages · Page 1 of 1 (latest)

mild harness
#

I'm working on a mixin that, when a specific message in the server pops up, registers and updates a variable. For some reason though, this only worked with me in singleplayer, when I tried joining a server to test it out, it just didn't work.

#
package hypixel.mod.mixin;

import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Objects;

@Mixin(ClientPlayNetworkHandler.class)
public class DungeonBlessings {

    @Unique
    public int blessingOfPower = 0, blessingOfWisdom = 0, blessingOfTime = 0;

    @Inject(method = "onChatMessage", at = @At("HEAD"))
    private void onChatMessage(ChatMessageS2CPacket packet, CallbackInfo ci) {
        String message = packet.body().content();
        // All the code...
    }
}
#

I'm still new to modding with fabric but I am just a little lost as to what I messed up