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

项目:CreeperHostGui    文件:CreeperHostServer.java   
@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());
    }
}
项目:qcraft-mod    文件:ConnectionHandler.java   
@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 );
}
项目:playblock    文件:PacketHandler.java   
@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);
    }
}
项目:Pay2Spawn    文件:ConnectionHandler.java   
@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);
    }
}
项目:4Space-5    文件:ConnectionPacket.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPacketData(FMLNetworkEvent.ClientCustomPacketEvent event)
{
    FMLProxyPacket pkt = event.packet;

    onFMLProxyPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer);
}
项目:4Space-5    文件:ConnectionPacket.java   
@SubscribeEvent
public void onPacketData(FMLNetworkEvent.ServerCustomPacketEvent event)
{
    FMLProxyPacket pkt = event.packet;

    onFMLProxyPacketData(event.manager, pkt, ((NetHandlerPlayServer)event.handler).playerEntity);
}
项目:TRHS_Club_Mod_2016    文件:FMLClientHandler.java   
@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));
    }
}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
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()));
}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
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);
}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
@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);
}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
@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);
}
项目:CauldronGit    文件:FMLClientHandler.java   
@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));
    }
}
项目:CauldronGit    文件:NetworkDispatcher.java   
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()));
}
项目:CauldronGit    文件:NetworkDispatcher.java   
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);
}
项目:CauldronGit    文件:NetworkDispatcher.java   
@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);
}
项目:CauldronGit    文件:NetworkDispatcher.java   
@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);
}
项目:amunra    文件:ConnectionPacketAR.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPacketData(FMLNetworkEvent.ClientCustomPacketEvent event)
{
    FMLProxyPacket pkt = event.packet;

    onFMLProxyPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer);
}
项目:amunra    文件:ConnectionPacketAR.java   
@SubscribeEvent
public void onPacketData(FMLNetworkEvent.ServerCustomPacketEvent event)
{
    FMLProxyPacket pkt = event.packet;

    onFMLProxyPacketData(event.manager, pkt, ((NetHandlerPlayServer)event.handler).playerEntity);
}
项目:qcraft-mod    文件:PacketHandler.java   
@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();
    }
}
项目:qcraft-mod    文件:PacketHandler.java   
@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();
    }
}
项目:Cauldron    文件:FMLClientHandler.java   
@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));
    }
}
项目:Cauldron    文件:NetworkDispatcher.java   
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()));
}
项目:Cauldron    文件:NetworkDispatcher.java   
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);
}
项目:Cauldron    文件:NetworkDispatcher.java   
@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);
}
项目:Cauldron    文件:NetworkDispatcher.java   
@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);
}
项目:Cauldron    文件:FMLClientHandler.java   
@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));
    }
}
项目:Cauldron    文件:NetworkDispatcher.java   
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()));
}
项目:Cauldron    文件:NetworkDispatcher.java   
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);
}
项目:Cauldron    文件:NetworkDispatcher.java   
@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);
}
项目:Cauldron    文件:NetworkDispatcher.java   
@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);
}
项目:Cauldron    文件:FMLClientHandler.java   
@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));
    }
}
项目:Cauldron    文件:NetworkDispatcher.java   
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()));
}
项目:Cauldron    文件:NetworkDispatcher.java   
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);
}
项目:Cauldron    文件:NetworkDispatcher.java   
@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);
}
项目:Cauldron    文件:NetworkDispatcher.java   
@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);
}
项目:playblock    文件:PacketHandler.java   
@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);
    }
}
项目:Obsidian    文件:ObsidianMod.java   
@SubscribeEvent
public void onClientConnectedToServerEvent(FMLNetworkEvent.ClientConnectedToServerEvent event) {
    if (event.isLocal) {
        final CommonAddonManager addonManager = (CommonAddonManager) game.getAddonManager();
        final CommonFileSystem fileSystem = (CommonFileSystem) game.getFileSystem();
        final CommonMessagePipeline messagePipeline = (CommonMessagePipeline) game.getPipeline();

        // Load addons
        addonManager.loadAddons(CommonFileSystem.ADDONS_PATH);

        // Initialize addons
        addonManager.initialize();

        // Register our language map into Forge
        ((CommonLanguageManager) game.getLanguages()).register();

        // Refresh for addon additions in initialize
        Minecraft.getMinecraft().refreshResources();

        // Lock filesystem
        fileSystem.lockFileSystem();

        // Lock message pipeline
        messagePipeline.lockPipeline();

        // Enable addons
        addonManager.enable();
    }
}
项目:VoxelPlayerModels    文件:EventHandler.java   
@SubscribeEvent
public void clientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) {
    proxy.getClientChannel().attr(FML_MESSAGETARGET).set(TOSERVER);
    String player = getMinecraft().thePlayer.func_146103_bH().getName();
    proxy.getClientChannel().writeOutbound(new PlayerDataPacket(player));
    proxy.getClientChannel().writeOutbound(new ClientDataPacket(player, ClientDataPacket.Messages.REQUEST));
}
项目:Pay2Spawn    文件:ConnectionHandler.java   
@SubscribeEvent
public void disconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    Pay2Spawn.reloadDB();
    StatusMessage.resetServerStatus();
    new Timer().schedule(new TimerTask()
    {
        @Override
        public void run()
        {
            if (!StatusMessage.doesServerHaveMod()) Helper.msg(EnumChatFormatting.RED + NAME + " isn't on the server. No rewards will spawn!");
        }
    }, 5 * 1000);
}
项目:VoxelPlayerModels    文件:EventHandler.java   
@SubscribeEvent
public void clientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) {
    proxy.getClientChannel().attr(FML_MESSAGETARGET).set(TOSERVER);
    String player = getMinecraft().thePlayer.func_146103_bH().getName();
    proxy.getClientChannel().writeOutbound(new PlayerDataPacket(player));
    proxy.getClientChannel().writeOutbound(new ClientDataPacket(player, ClientDataPacket.Messages.REQUEST));
}