This commit is contained in:
Chayapak 2023-05-07 15:16:09 +07:00
parent 83671e103e
commit 4d1a594cca
2 changed files with 10 additions and 1 deletions

View file

@ -7,4 +7,6 @@ public class Listener {
public void chatMessageReceived (Text message) {}
public void packetReceived (Packet packet) {}
public void packetSent (Packet packet) {}
}

View file

@ -31,7 +31,7 @@ public class ClientConnectionMixin {
}
@Inject(method = "handlePacket", at = @At("HEAD"), cancellable = true)
private static void handlePacket (Packet packet, PacketListener _listener, CallbackInfo ci) {
private static void handlePacket (Packet<?> packet, PacketListener _listener, CallbackInfo ci) {
// please don't skid this.,.
// mabe mabe mabe
if (packet instanceof ParticleS2CPacket t_packet) {
@ -46,4 +46,11 @@ public class ClientConnectionMixin {
listener.packetReceived(packet);
}
}
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("TAIL"))
private static void sendPacket (Packet<?> packet, CallbackInfo ci) {
for (Listener listener : ListenerManager.listeners) {
listener.packetSent(packet);
}
}
}