File tree Expand file tree Collapse file tree
1.19.4/src/main/java/net/Poluteclient/phosphor/mixin Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package net .Poluteclient .phosphor .mixin ;
2+
3+ import net .Poluteclient .phosphor .common .Phosphor ;
4+ import net .Poluteclient .phosphor .api .event .events .PacketEvent ;
5+ import net .minecraft .network .ClientConnection ;
6+ import net .minecraft .network .listener .PacketListener ;
7+ import net .minecraft .network .packet .Packet ;
8+ import org .spongepowered .asm .mixin .Mixin ;
9+ import org .spongepowered .asm .mixin .injection .At ;
10+ import org .spongepowered .asm .mixin .injection .Inject ;
11+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
12+
13+ @ Mixin (ClientConnection .class )
14+ public class ClientConnectionMixin {
15+ @ Inject (method = "handlePacket" ,
16+ at = @ At ("HEAD" ),
17+ cancellable = true )
18+ private static <T extends PacketListener > void handlePacket (Packet <T > packet , PacketListener listener , CallbackInfo ci ) {
19+ if (Phosphor .EVENTBUS .post (PacketEvent .Receive .get (packet )).isCancelled ()) ci .cancel ();
20+ }
21+
22+ @ Inject (method = "send(Lnet/minecraft/network/packet/Packet;)V" ,
23+ at = @ At ("HEAD" ),
24+ cancellable = true )
25+ private void onPacketSend (Packet <?> packet , CallbackInfo ci ) {
26+ if (Phosphor .EVENTBUS .post (PacketEvent .Send .get (packet )).isCancelled ()) ci .cancel ();
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments