diff options
author | syeyoung <cyong06@naver.com> | 2021-01-08 12:01:51 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-08 12:01:51 +0900 |
commit | a248c240b2d8164453ac2269e71bd64ce26ae373 (patch) | |
tree | bf22f3c55e37a7cbe924e0dd8afc63e93bb68427 /src/main/java/kr/syeyoung | |
parent | 0b364456085c0ae48797aa5b7b2864f47735f509 (diff) | |
download | Skyblock-Dungeons-Guide-a248c240b2d8164453ac2269e71bd64ce26ae373.tar.gz Skyblock-Dungeons-Guide-a248c240b2d8164453ac2269e71bd64ce26ae373.tar.bz2 Skyblock-Dungeons-Guide-a248c240b2d8164453ac2269e71bd64ce26ae373.zip |
packets
Diffstat (limited to 'src/main/java/kr/syeyoung')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java index a0a52454..9252a03d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide.eventlistener; import io.netty.channel.ChannelDuplexHandler; +import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import kr.syeyoung.dungeonsguide.SkyblockStatus; @@ -14,6 +15,7 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent; import java.lang.reflect.Field; +@ChannelHandler.Sharable public class PacketListener extends ChannelDuplexHandler { private SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus();; @Override @@ -33,30 +35,17 @@ public class PacketListener extends ChannelDuplexHandler { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { -// if (ToggleCommand.itemFrameOnSeaLanternsToggled && Utils.inDungeons && msg instanceof Packet && msg.getClass().getName().endsWith("C02PacketUseEntity")) { -// Minecraft mc = Minecraft.getMinecraft(); -// C02PacketUseEntity packet = (C02PacketUseEntity) msg; -// Entity entityHit = packet.getEntityFromWorld(mc.theWorld); -// if (entityHit instanceof EntityItemFrame) { -// EntityItemFrame itemFrame = (EntityItemFrame) entityHit; -// ItemStack item = itemFrame.getDisplayedItem(); -// if (item != null && item.getItem() == Items.arrow) { -// BlockPos blockPos = Utils.getBlockUnderItemFrame(itemFrame); -// if (mc.theWorld.getBlockState(blockPos).getBlock() == Blocks.sea_lantern) { -// return; -// } -// } -// } -// } - super.write(ctx, msg, promise); } @SubscribeEvent public void onServerConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { if (event.manager.channel().pipeline().get("dg_packet_handler") != null) - event.manager.channel().pipeline().remove(this); - - event.manager.channel().pipeline().addBefore("packet_handler", "dg_packet_handler", this); + event.manager.channel().pipeline().remove(this); + try { + event.manager.channel().pipeline().addBefore("packet_handler", "dg_packet_handler", this); + } catch (Exception e) { + e.printStackTrace(); + } } } |