@SubscribeEvent public void onServerPacket(ServerCustomPacketEvent event) throws IOException { ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload()); EntityPlayer entityPlayer = ((NetHandlerPlayServer) event.handler).playerEntity; int packetId = bbis.readInt(); if (packetId < packetCarrier.size()) { try { ICarpentersPacket packetClass = (ICarpentersPacket) packetCarrier.get(packetId).newInstance(); packetClass.processData(entityPlayer, bbis); } catch (Exception e) { e.printStackTrace(); } } else { ModLogger.log(Level.WARN, "Encountered out of range packet Id: " + packetId); } bbis.close(); }
@SubscribeEvent public void onPacket(ServerCustomPacketEvent event) { if( event.packet.channel().equals(Version.CHANNEL) ) { final NetHandlerPlayServer handler = (NetHandlerPlayServer)event.handler; handlePacket( event.packet, handler.playerEntity ); } }
@SubscribeEvent public void serverPacket(ServerCustomPacketEvent ev) { NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.packet.handler(); if ( serveHandler != null ) serveHandler.onPacketData( ev.packet, srv.playerEntity ); }
@SubscribeEvent public void onPacketData(ServerCustomPacketEvent event) { FMLProxyPacket pkt = event.packet; onPacketData(event.manager, pkt, ((NetHandlerPlayServer) event.handler).playerEntity); }
@SubscribeEvent public void onPacket(ServerCustomPacketEvent event) { this.parseAndDispatchPacket(event.packet.payload(), ((NetHandlerPlayServer)event.handler).playerEntity); }