From 01e4c0dfb2a9726a9bf1c4d1a1fe28edbc3d094c Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sat, 28 May 2022 12:02:04 +0700 Subject: OC-32 OC-34 (#24) * OC-34 hypixel utils class (#21) * OC-26 Build Workflow * OC-26 oops * OC-33 some networking utils * OC-34 idk * OC-34 idk * OC-34 restructure hypixel utils * hypixelutils and multithreading implement more events remove vcal icon stuff * more javadocs Co-authored-by: Ethan --- .../oneconfig/mixin/NetHandlerPlayClientMixin.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/cc/polyfrost/oneconfig/mixin/NetHandlerPlayClientMixin.java (limited to 'src/main/java/cc/polyfrost/oneconfig/mixin/NetHandlerPlayClientMixin.java') diff --git a/src/main/java/cc/polyfrost/oneconfig/mixin/NetHandlerPlayClientMixin.java b/src/main/java/cc/polyfrost/oneconfig/mixin/NetHandlerPlayClientMixin.java new file mode 100644 index 0000000..c7056d5 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/mixin/NetHandlerPlayClientMixin.java @@ -0,0 +1,24 @@ +package cc.polyfrost.oneconfig.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ChatReceiveEvent; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.play.server.S02PacketChat; +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(NetHandlerPlayClient.class) +public class NetHandlerPlayClientMixin { + @Inject(method = "handleChat", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onClientChat(BLnet/minecraft/util/IChatComponent;)Lnet/minecraft/util/IChatComponent;", remap = false), cancellable = true, remap = true) + private void onClientChat(S02PacketChat packetIn, CallbackInfo ci) { + if (packetIn.getType() == 0) { + ChatReceiveEvent event = new ChatReceiveEvent(packetIn.getChatComponent()); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } + } +} -- cgit