Java 类net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent 实例源码

项目:Ambidextrous    文件:NetworkRouter.java   
@SubscribeEvent
public void clientPacket(
        final ClientCustomPacketEvent ev )
{
    try
    {
        if ( clientPacketHandler != null )
        {
            clientPacketHandler.onPacketData( ev.getPacket(), ev.getHandler() );
        }
    }
    catch ( final ThreadQuickExitException ext )
    {
        ;
    }
}
项目:morecommands    文件:PacketDispatcher.java   
/**
 * Invoked when the client receives a packet from the server
 */
@SubscribeEvent
public void onServerPacket(final ClientCustomPacketEvent event) {
    if (!event.getPacket().channel().equals(Reference.CHANNEL)) return;

    Minecraft.getMinecraft().addScheduledTask(new Runnable() {
        @Override
        public void run() {
            try {handleServerPacket(event.getPacket());}
            catch (Exception ex) {
                ex.printStackTrace(); 
                MoreCommands.INSTANCE.getLogger().warn("Error handling Packet");
            }
        }
    });
}
项目:Factorization    文件:MiscNet.java   
@SubscribeEvent
public void onPacketData(ClientCustomPacketEvent event) {
    FMLProxyPacket packet = event.packet;
    packet.payload().array();
    try {
        ByteBufInputStream input = new ByteBufInputStream(event.packet.payload());
        MiscellaneousNonsense.proxy.handleTpsReport(input.readFloat());
        input.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return;
}
项目:Factorization    文件:FzNetEventHandler.java   
@SubscribeEvent
public void onPacket(final ClientCustomPacketEvent event) {
    if (!Core.proxy.isClientThread()) {
        Core.proxy.addScheduledClientTask(new Runnable() {
            public void run() {
                handlePacket(event, false, Core.proxy.getClientPlayer());
            }
        });
    } else {
        handlePacket(event, false, Core.proxy.getClientPlayer());
    }
}
项目:Factorization    文件:NotifyNetwork.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void recievePacket(ClientCustomPacketEvent event) {
    ByteBufInputStream input = new ByteBufInputStream(event.packet.payload());
    try {
        handleNotify(input, Minecraft.getMinecraft().thePlayer);
    } catch (IOException e) {
        e.printStackTrace();
    }
}