Java 类cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent 实例源码

项目:carpentersblocks    文件:PacketHandler.java   
@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();
}
项目:FairyFactions    文件:FairyEventListener.java   
@SubscribeEvent
public void onPacket(ServerCustomPacketEvent event) {
    if( event.packet.channel().equals(Version.CHANNEL) ) {
        final NetHandlerPlayServer handler = (NetHandlerPlayServer)event.handler;
        handlePacket( event.packet, handler.playerEntity );
    }
}
项目:RotatableBlocks    文件:NetworkHandler.java   
@SubscribeEvent
public void serverPacket(ServerCustomPacketEvent ev)
{
    NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.packet.handler();
    if ( serveHandler != null )
        serveHandler.onPacketData( ev.packet, srv.playerEntity );
}
项目:LookingGlass    文件:LookingGlassPacketManager.java   
@SubscribeEvent
public void onPacketData(ServerCustomPacketEvent event) {
    FMLProxyPacket pkt = event.packet;

    onPacketData(event.manager, pkt, ((NetHandlerPlayServer) event.handler).playerEntity);
}
项目:MagicBees    文件:NetworkEventHandler.java   
@SubscribeEvent
public void onPacket(ServerCustomPacketEvent event) {
    this.parseAndDispatchPacket(event.packet.payload(), ((NetHandlerPlayServer)event.handler).playerEntity);
}
项目:ShadowsOfPhysis    文件:PhysisPacketHandler.java   
@SubscribeEvent
public void onPacketData(ServerCustomPacketEvent event) {
    FMLProxyPacket pkt = event.packet;

    onPacketData(event.manager, pkt, ((NetHandlerPlayServer) event.handler).playerEntity);
}