diff options
Diffstat (limited to 'src/main/java/me/Danker/handlers/PacketHandler.java')
-rw-r--r-- | src/main/java/me/Danker/handlers/PacketHandler.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/main/java/me/Danker/handlers/PacketHandler.java b/src/main/java/me/Danker/handlers/PacketHandler.java index a4fd85e..a5a858b 100644 --- a/src/main/java/me/Danker/handlers/PacketHandler.java +++ b/src/main/java/me/Danker/handlers/PacketHandler.java @@ -2,29 +2,30 @@ package me.Danker.handlers; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; -import me.Danker.utils.Utils; -import net.minecraft.client.Minecraft; +import io.netty.channel.ChannelPromise; +import me.Danker.events.PacketReadEvent; +import me.Danker.events.PacketWriteEvent; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S04PacketEntityEquipment; - -import java.lang.reflect.Field; +import net.minecraftforge.common.MinecraftForge; public class PacketHandler extends ChannelDuplexHandler { - - // Spirit boots fix + @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - if (Utils.inSkyblock && msg instanceof Packet && msg.getClass().getName().endsWith("S04PacketEntityEquipment")) { // Inventory packet name - S04PacketEntityEquipment packet = (S04PacketEntityEquipment) msg; - if (packet.getEntityID() == Minecraft.getMinecraft().thePlayer.getEntityId()) { - Field slot = packet.getClass().getDeclaredField("field_149392_b"); // equipmentSlot - slot.setAccessible(true); - slot.setInt(packet, slot.getInt(packet) + 1); - msg = packet; - } + if (msg instanceof Packet) { + if (MinecraftForge.EVENT_BUS.post(new PacketReadEvent((Packet) msg))) return; } - + super.channelRead(ctx, msg); } + + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + if (msg instanceof Packet) { + if (MinecraftForge.EVENT_BUS.post(new PacketWriteEvent((Packet) msg))) return; + } + + super.write(ctx, msg, promise); + } } |