当前位置: 首页>>代码示例>>Java>>正文


Java FMLNetworkEvent类代码示例

本文整理汇总了Java中cpw.mods.fml.common.network.FMLNetworkEvent的典型用法代码示例。如果您正苦于以下问题:Java FMLNetworkEvent类的具体用法?Java FMLNetworkEvent怎么用?Java FMLNetworkEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FMLNetworkEvent类属于cpw.mods.fml.common.network包,在下文中一共展示了FMLNetworkEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clientConnectedtoServer

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void clientConnectedtoServer(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
    if (!CreeperHost.instance.active)
        return;
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null || server.isSinglePlayer() || discoverMode != Discoverability.PUBLIC)
        return;

    INetHandlerPlayServer handler = event.handler;
    if (handler instanceof NetHandlerPlayServer)
    {
        EntityPlayerMP entity = ((NetHandlerPlayServer) handler).playerEntity;
        playersJoined.add(entity.getUniqueID());
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:17,代码来源:CreeperHostServer.java

示例2: connectionOpened

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void connectionOpened( FMLNetworkEvent.ClientConnectedToServerEvent event )
{
    if( !event.isLocal )
    {
        SocketAddress socketAddress = event.manager.getSocketAddress();
        if( socketAddress != null && socketAddress instanceof InetSocketAddress )
        {
            InetSocketAddress internet = (InetSocketAddress)socketAddress;
            String hostString = null;
            try
            {
                Method getHostString = InetSocketAddress.class.getDeclaredMethod( "getHostString", new Class[]{} );
                getHostString.setAccessible( true );
                hostString = getHostString.invoke( internet ).toString();
            }
            catch( Exception e )
            {
                hostString = internet.getHostName();
            }
            QCraft.setCurrentServerAddress( hostString + ":" + internet.getPort() );
            return;
        }
    }
    QCraft.setCurrentServerAddress( null );
}
 
开发者ID:TeacherGaming,项目名称:qcraft-mod,代码行数:27,代码来源:ConnectionHandler.java

示例3: onReceiveClient

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onReceiveClient(FMLNetworkEvent.ClientCustomPacketEvent evt) {
    World world = Minecraft.getMinecraft().theWorld;
    EntityPlayer entityPlayer = Minecraft.getMinecraft().thePlayer;
    try {
        ByteBufInputStream in = new ByteBufInputStream(evt.packet.payload());

        // Read the container
        PlayBlockPayload container = new PlayBlockPayload();
        container.read(in);

        // Figure out what we are containing
        switch (container.getType()) {
        case TILE_ENTITY:
            handleTilePayload(world, entityPlayer, in);
            break;
        case TILE_ENTITY_NBT:
            handleNetworkedNBT(world, evt.packet.payload());
        }
    } catch (IOException e) {
        PlayBlock.log(Level.WARN, "Failed to read packet data from " + entityPlayer.getDisplayName(), e);
    }
}
 
开发者ID:sk89q,项目名称:playblock,代码行数:25,代码来源:PacketHandler.java

示例4: connectionReceived

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void connectionReceived(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
    if (!event.isLocal && Pay2Spawn.getConfig().forceP2S)
    {
        final String username = ((NetHandlerPlayServer) event.handler).playerEntity.getCommandSenderName();
        new Timer().schedule(new TimerTask()
        {
            @Override
            public void run()
            {
                if (!StatusMessage.doesPlayerHaveValidConfig(username)) MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(username).playerNetServerHandler.kickPlayerFromServer("Pay2Spawn is required on this server.\nIt needs to be configured properly.");
            }
        }, 5 * 1000);
    }
}
 
开发者ID:CCM-Modding,项目名称:Pay2Spawn,代码行数:17,代码来源:ConnectionHandler.java

示例5: onPacketData

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPacketData(FMLNetworkEvent.ClientCustomPacketEvent event)
{
	FMLProxyPacket pkt = event.packet;

	onFMLProxyPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer);
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:9,代码来源:ConnectionPacket.java

示例6: fireNetRegistrationEvent

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
{
    if (side == Side.CLIENT)
    {
        waitForPlayClient();
        bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayClient>(manager, channelSet, channel, side, NetHandlerPlayClient.class));
    }
    else
    {
        bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayServer>(manager, channelSet, channel, side, NetHandlerPlayServer.class));
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:14,代码来源:FMLClientHandler.java

示例7: completeClientSideConnection

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private void completeClientSideConnection(ConnectionType type)
{
    this.connectionType = type;
    FMLLog.info("[%s] Client side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
    this.state = ConnectionState.CONNECTED;
    FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name()));
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:8,代码来源:NetworkDispatcher.java

示例8: completeServerSideConnection

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private void completeServerSideConnection(ConnectionType type)
{
    this.connectionType = type;
    FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
    this.state = ConnectionState.CONNECTED;
    FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
    scm.func_72355_a(manager, player, serverHandler);
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:9,代码来源:NetworkDispatcher.java

示例9: disconnect

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
    if (side == Side.CLIENT)
    {
        FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
    }
    else
    {
        FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
    }
    cleanAttributes(ctx);
    ctx.disconnect(promise);
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:15,代码来源:NetworkDispatcher.java

示例10: close

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
    if (side == Side.CLIENT)
    {
        FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
    }
    else
    {
        FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
    }
    cleanAttributes(ctx);
    ctx.close(promise);
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:15,代码来源:NetworkDispatcher.java

示例11: completeServerSideConnection

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
private void completeServerSideConnection(ConnectionType type)
{
    this.connectionType = type;
    FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
    this.state = ConnectionState.CONNECTED;
    FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
    scm.initializeConnectionToPlayer(manager, player, serverHandler);
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:9,代码来源:NetworkDispatcher.java

示例12: onPacketData

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPacketData(FMLNetworkEvent.ClientCustomPacketEvent event)
{
    FMLProxyPacket pkt = event.packet;

    onFMLProxyPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer);
}
 
开发者ID:katzenpapst,项目名称:amunra,代码行数:9,代码来源:ConnectionPacketAR.java

示例13: onClientPacket

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onClientPacket( FMLNetworkEvent.ClientCustomPacketEvent event )
{
    try
    {
        QCraftPacket packet = new QCraftPacket();
        packet.fromBytes( event.packet.payload() );
        QCraft.handleClientPacket( packet );
    }
    catch( Exception e )
    {
        // Something failed, ignore it
        e.printStackTrace();
    }
}
 
开发者ID:TeacherGaming,项目名称:qcraft-mod,代码行数:16,代码来源:PacketHandler.java

示例14: onServerPacket

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onServerPacket( FMLNetworkEvent.ServerCustomPacketEvent event )
{
    try
    {
        QCraftPacket packet = new QCraftPacket();
        packet.fromBytes( event.packet.payload() );
        QCraft.handleServerPacket( packet, ((NetHandlerPlayServer)event.handler).playerEntity );
    }
    catch( Exception e )
    {
        // Something failed, ignore it
        e.printStackTrace();
    }
}
 
开发者ID:TeacherGaming,项目名称:qcraft-mod,代码行数:16,代码来源:PacketHandler.java

示例15: onReceiveServer

import cpw.mods.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onReceiveServer(FMLNetworkEvent.ServerCustomPacketEvent evt) {
    EntityPlayer entityPlayer = ((NetHandlerPlayServer) evt.handler).playerEntity;
    World world;

    // Get the world
    if (entityPlayer != null) {
        world = entityPlayer.worldObj;
    } else {
        PlayBlock.log(Level.WARN, "Received an update packet from an invalid player!");
        return;
    }

    try {
        ByteBufInputStream in = new ByteBufInputStream(evt.packet.payload());

        // Read the container
        PlayBlockPayload container = new PlayBlockPayload();
        container.read(in);

        // Figure out what we are containing
        switch (container.getType()) {
        case TILE_ENTITY:
            handleTilePayload(world, entityPlayer, in);
            break;
        case TILE_ENTITY_NBT:
            handleNetworkedNBT(world, evt.packet.payload());
        }
    } catch (IOException e) {
        PlayBlock.log(Level.WARN, "Failed to read packet data from " + entityPlayer.getDisplayName(), e);
    }
}
 
开发者ID:sk89q,项目名称:playblock,代码行数:33,代码来源:PacketHandler.java


注:本文中的cpw.mods.fml.common.network.FMLNetworkEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。