diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 5394a23..1478f40 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -11,6 +11,5 @@
-
-
+
\ No newline at end of file
diff --git a/src/main/java/me/allinkdev/deviousmod/mixin/client/network/PacketSendAndReceive.java b/src/main/java/me/allinkdev/deviousmod/mixin/client/network/PacketSendAndReceive.java
new file mode 100644
index 0000000..7d22990
--- /dev/null
+++ b/src/main/java/me/allinkdev/deviousmod/mixin/client/network/PacketSendAndReceive.java
@@ -0,0 +1,26 @@
+package me.allinkdev.deviousmod.mixin.client.network;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPipeline;
+import me.allinkdev.deviousmod.packet.PacketHandler;
+import me.allinkdev.deviousmod.packet.PrePacketHandler;
+import net.minecraft.network.ClientConnection;
+import net.minecraft.network.NetworkSide;
+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(ClientConnection.class)
+public final class PacketSendAndReceive {
+ @Inject(method = "addHandlers", at = @At(value = "TAIL"))
+ private static void onAddHandlers(final ChannelPipeline pipeline, final NetworkSide side, final CallbackInfo ci) {
+ if (!side.equals(NetworkSide.CLIENTBOUND)) return;
+ pipeline.addFirst(new PrePacketHandler());
+ }
+
+ @Inject(method = "channelActive", at = @At(value = "TAIL"))
+ private void onChannelActive(final ChannelHandlerContext context, final CallbackInfo ci) {
+ context.pipeline().addBefore("packet_handler", null, new PacketHandler());
+ }
+}
diff --git a/src/main/java/me/allinkdev/deviousmod/mixin/client/network/packet/PacketSendAndReceive.java b/src/main/java/me/allinkdev/deviousmod/mixin/client/network/packet/PacketSendAndReceive.java
deleted file mode 100644
index ffdaa52..0000000
--- a/src/main/java/me/allinkdev/deviousmod/mixin/client/network/packet/PacketSendAndReceive.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package me.allinkdev.deviousmod.mixin.client.network.packet;
-
-import io.netty.channel.ChannelHandlerContext;
-import me.allinkdev.deviousmod.event.network.packet.impl.PacketC2SEvent;
-import me.allinkdev.deviousmod.event.network.packet.impl.PacketS2CEvent;
-import me.allinkdev.deviousmod.util.EventUtil;
-import net.minecraft.network.ClientConnection;
-import net.minecraft.network.PacketCallbacks;
-import net.minecraft.network.packet.Packet;
-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(ClientConnection.class)
-public final class PacketSendAndReceive {
- @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
- //CHECKSTYLE:OFF
- public void onReceive(final ChannelHandlerContext channelHandlerContext, Packet> packet, final CallbackInfo ci) {
- //CHECKSTYLE:ON
- final var event = EventUtil.postEvent(new PacketS2CEvent(packet));
- final var eventPacket = event.getPacket();
-
- if (event.isCancelled() || eventPacket == null) ci.cancel();
- packet = eventPacket;
- }
-
- @Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", at = @At("HEAD"), cancellable = true)
- //CHECKSTYLE:OFF
- private void onSend(Packet> packet, final PacketCallbacks callbacks, final CallbackInfo ci) {
- //CHECKSTYLE:ON
- final var event = EventUtil.postEvent(new PacketC2SEvent(packet));
- final var eventPacket = event.getPacket();
-
- if (event.isCancelled() || eventPacket == null) ci.cancel();
- packet = eventPacket;
- }
-}
diff --git a/src/main/java/me/allinkdev/deviousmod/mixin/client/network/packet/RawPacketReceive.java b/src/main/java/me/allinkdev/deviousmod/mixin/client/network/packet/RawPacketReceive.java
deleted file mode 100644
index f0ea4a8..0000000
--- a/src/main/java/me/allinkdev/deviousmod/mixin/client/network/packet/RawPacketReceive.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package me.allinkdev.deviousmod.mixin.client.network.packet;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import me.allinkdev.deviousmod.event.network.packet.impl.PrePacketS2CEvent;
-import me.allinkdev.deviousmod.util.EventUtil;
-import net.minecraft.network.DecoderHandler;
-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;
-
-import java.util.Arrays;
-import java.util.List;
-
-@Mixin(DecoderHandler.class)
-public class RawPacketReceive {
-
- @Inject(method = "decode", at = @At("HEAD"))
- private void onDecode(final ChannelHandlerContext ctx, final ByteBuf buf, final List