blob: c7056d58fe0e0eef97e438e01cb4616a45f7b4b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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();
}
}
}
}
|