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

项目:justenoughdimensions    文件:JEDEventHandler.java   
@SubscribeEvent
public void onConnectionCreated(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
    JustEnoughDimensions.logInfo("FMLNetworkEvent.ServerConnectionFromClientEvent: Syncing dimension data to client");
    DimensionSyncPacket packet = new DimensionSyncPacket();
    packet.addDimensionData(DimensionConfig.instance().getRegisteredDimensions());

    FMLEmbeddedChannel channel = JustEnoughDimensions.channels.get(Side.SERVER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.getManager().channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
    channel.writeOutbound(packet);
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
private void cleanAttributes(ChannelHandlerContext ctx)
{
    ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).remove();
    ctx.channel().attr(NetworkRegistry.NET_HANDLER).remove();
    ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).remove();
    this.handshakeChannel.attr(FML_DISPATCHER).remove();
    this.manager.channel().attr(FML_DISPATCHER).remove();
}
项目:CustomWorldGen    文件:SimpleChannelHandlerWrapper.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, REQ msg) throws Exception
{
    INetHandler iNetHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
    MessageContext context = new MessageContext(iNetHandler, side);
    REPLY result = messageHandler.onMessage(msg, context);
    if (result != null)
    {
        ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.REPLY);
        ctx.writeAndFlush(result).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
    }
}
项目:CustomWorldGen    文件:FMLNetworkHandler.java   
public static void registerChannel(FMLContainer container, Side side)
{
    channelPair = NetworkRegistry.INSTANCE.newChannel(container, "FML", new FMLRuntimeCodec(), new HandshakeCompletionHandler());
    EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
    embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);

    if (side == Side.CLIENT)
    {
        addClientHandlers();
    }
}
项目:CustomWorldGen    文件:ForgeNetworkHandler.java   
public static void registerChannel(ForgeModContainer forgeModContainer, Side side)
{
    channelPair = NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FORGE", new ForgeRuntimeCodec());
    if (side == Side.CLIENT)
    {
        addClientHandlers();
    }

    FMLEmbeddedChannel serverChannel = channelPair.get(Side.SERVER);
    serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);
    String handlerName = serverChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class);
    serverChannel.pipeline().addAfter(handlerName, "ServerToClientConnection", new ServerToClientConnectionEstablishedHandler());
}
项目:CodeChickenLib    文件:PacketCustom.java   
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {

    if (evt instanceof NetworkHandshakeEstablished) {
        INetHandler netHandler = ((NetworkDispatcher) ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).get()).getNetHandler();
        if (netHandler instanceof NetHandlerPlayServer) {
            handler.handshakeReceived((NetHandlerPlayServer) netHandler);
        }
    } else {
        ctx.fireUserEventTriggered(evt);
    }
}
项目:HazardousResearch    文件:PacketHandler.java   
public static void sendPacketToPlayer(SimplePacket packet, EntityPlayer player)
{
    PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
            .set(FMLOutboundHandler.OutboundTarget.PLAYER);
    PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet);
}
项目:HazardousResearch    文件:PacketHandler.java   
public static void sendPacketToAllPlayers(SimplePacket packet)
{
    PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
            .set(FMLOutboundHandler.OutboundTarget.ALL);
    PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet);

}
项目:SpaceCore    文件:PacketCodec.java   
public void sendToPlayer( EntityPlayerMP player, Packet packet )
{
    Channel channel = channels.get( Side.SERVER );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.PLAYER );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGETARGS ).set( player );
    channel.writeAndFlush( packet );
}
项目:SpaceCore    文件:PacketCodec.java   
public void sendToNearby( NetworkRegistry.TargetPoint pos, Packet packet )
{
    Channel channel = channels.get( Side.SERVER );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGETARGS ).set( pos );
    channel.writeAndFlush( packet );
}
项目:SpaceCore    文件:PacketCodec.java   
public void sendToDimension( int dim, Packet packet )
{
    Channel channel = channels.get( Side.SERVER );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.DIMENSION );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGETARGS ).set( dim );
    channel.writeAndFlush( packet );
}
项目:SpaceCore    文件:PacketCodec.java   
@SideOnly( Side.CLIENT )
public void sendToServer( Packet packet )
{
    Channel channel = channels.get( Side.CLIENT );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.TOSERVER );
    channel.writeAndFlush( packet );
}
项目:OpenModsLib    文件:NetworkEventInboundHandler.java   
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final NetworkEvent msg) throws Exception {
    NetUtils.executeSynchronized(ctx, () -> {
        // TODO asynchronous events, once needed
        MinecraftForge.EVENT_BUS.post(msg);
        msg.dispatcher = null;

        for (NetworkEvent reply : msg.replies) {
            ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.REPLY);
            ctx.writeAndFlush(reply);
        }
    });
}
项目:OpenModsLib    文件:ExtendedOutboundHandler.java   
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
    if (!(msg instanceof FMLProxyPacket)) {
        ctx.write(msg);
        return;
    }

    final Channel channel = ctx.channel();

    final IPacketTargetSelector<?> target = channel.attr(MESSAGETARGET).get();
    if (target == null) {
        ctx.write(msg);
        return;
    }

    final FMLProxyPacket pkt = (FMLProxyPacket)msg;

    final Side channelSide = channel.attr(NetworkRegistry.CHANNEL_SOURCE).get();

    Preconditions.checkState(target.isAllowedOnSide(channelSide), "Packet not allowed on side");

    final String channelName = channel.attr(NetworkRegistry.FML_CHANNEL).get();

    Object arg = channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).get();

    try {
        final Collection<NetworkDispatcher> dispatchers = getDispatchers(target, arg);
        for (NetworkDispatcher dispatcher : dispatchers)
            dispatcher.sendProxy(pkt);

    } catch (Throwable t) {

        throw new IllegalStateException(String.format(
                "Failed to select and send message (selector %s, arg: %s, channel: %s, side: %s)",
                target, arg, channelName, channelSide), t);
    }

}
项目:FFS    文件:NetworkHandler.java   
public static void sendPacketToPlayer(FFSPacket packet, EntityPlayer player) {
    FMLEmbeddedChannel channel = channels.get(Side.SERVER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    channel.writeOutbound(packet);
}
项目:FFS    文件:NetworkHandler.java   
public static void sendPacketToAllPlayers(FFSPacket packet) {
    FMLEmbeddedChannel channel = channels.get(Side.SERVER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
    channel.writeOutbound(packet);
}
项目:FFS    文件:NetworkHandler.java   
public static void sendPacketToServer(FFSPacket packet) {
    FMLEmbeddedChannel channel = channels.get(Side.CLIENT);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
    channel.writeOutbound(packet);
}
项目:HazardousResearch    文件:PacketHandler.java   
public static void sendPacketToServer(SimplePacket packet)
{
    PacketHandler.getChannels().get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET)
            .set(FMLOutboundHandler.OutboundTarget.TOSERVER);
    PacketHandler.getChannels().get(Side.CLIENT).writeOutbound(packet);
}
项目:NOVA-Core    文件:MCNetworkManager.java   
/**
 * @param packet the packet to send to the player
 * @param player the player MP object
 */
public void sendToPlayer(PacketAbstract packet, EntityPlayerMP player) {
    this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
    this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    this.channelEnumMap.get(Side.SERVER).writeAndFlush(packet);
}
项目:NOVA-Core    文件:MCNetworkManager.java   
/**
 * @param packet the packet to send to the players in the dimension
 * @param dimId the dimension id to send to.
 */
public void sendToAllInDimension(PacketAbstract packet, int dimId) {
    this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
    this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimId);
    this.channelEnumMap.get(Side.SERVER).writeAndFlush(packet);
}
项目:NOVA-Core    文件:MCNetworkManager.java   
/**
 * sends to all clients connected to the server
 * @param packet the packet to send.
 */
public void sendToAll(PacketAbstract packet) {
    this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
    this.channelEnumMap.get(Side.SERVER).writeAndFlush(packet);
}
项目:NOVA-Core    文件:MCNetworkManager.java   
public void sendToAllAround(PacketAbstract message, NetworkRegistry.TargetPoint point) {
    this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
    this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
    this.channelEnumMap.get(Side.SERVER).writeAndFlush(message);
}
项目:NOVA-Core    文件:MCNetworkManager.java   
@SideOnly(Side.CLIENT)
public void sendToServer(PacketAbstract packet) {
    this.channelEnumMap.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
    this.channelEnumMap.get(Side.CLIENT).writeAndFlush(packet);
}
项目:SasaLib    文件:PacketDispatcher.java   
public void sendToServer(SasaPacketBase packet)
{
    channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
    channels.get(Side.CLIENT).writeOutbound(packet);
}
项目:SasaLib    文件:PacketDispatcher.java   
public void sendToPlayer(SasaPacketBase packet, EntityPlayer player)
{
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    channels.get(Side.SERVER).writeOutbound(packet);
}
项目:SasaLib    文件:PacketDispatcher.java   
public void sendToAll(SasaPacketBase packet)
{
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
    channels.get(Side.SERVER).writeOutbound(packet);
}
项目:SasaLib    文件:PacketDispatcher.java   
public void sendToAllAround(SasaPacketBase packet, World world, int x, int y, int z)
{
    (INSTANCE.channels.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
    (INSTANCE.channels.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(new NetworkRegistry.TargetPoint(world.provider.getDimensionId(), x, y, z, 192.0D));
    (INSTANCE.channels.get(Side.SERVER)).writeAndFlush(packet);
}
项目:SasaLib    文件:PacketDispatcher.java   
public void sendToDimension(SasaPacketBase packet, int dimension)
{
    (INSTANCE.channels.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
    (INSTANCE.channels.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(Integer.valueOf(dimension));
    (INSTANCE.channels.get(Side.SERVER)).writeAndFlush(packet);
}
项目:SpaceCore    文件:PacketCodec.java   
public void sendToAll( Packet packet )
{
    Channel channel = channels.get( Side.SERVER );
    channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.ALL );
    channel.writeAndFlush( packet );
}
项目:Real-Life-Mod-1.8    文件:PacketHandler.java   
public void sendToServer(RLMPacketBase packet) {
    channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET)
            .set(FMLOutboundHandler.OutboundTarget.TOSERVER);
    channels.get(Side.CLIENT).writeAndFlush(packet);
}
项目:Achievement-Get    文件:AchievementChannel.java   
public void sendTo(EntityPlayerMP player, Packet packet) {
    this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER);
    this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    this.channels.get(Side.SERVER).writeAndFlush(packet);
}
项目:IvToolkit    文件:IvNetworkHelperServer.java   
public static void sendToPlayer(Channel channel, EntityPlayerMP playerMP, Object message)
{
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(playerMP);
    channel.writeAndFlush(message);
}
项目:Combustible-Lemon-Launcher    文件:CommonProxy.java   
public void packetCLL_sendToPlayer(CLLPacket packet, EntityPlayerMP player){
    cllChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
    cllChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    cllChannel.get(Side.SERVER).writeAndFlush(packet);
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
@Override
protected void configureChannel(Channel channel) {
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(selector);
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
@Override
protected void configureChannel(Channel channel, T target) {
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(selector);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(target);
}
项目:OpenModsLib    文件:ExtPacketSenderFactory.java   
@Override
protected void configureChannel(Channel channel, T target) {
    channel.attr(ExtendedOutboundHandler.MESSAGETARGET).set(selector);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(target);
}
项目:iChunUtil    文件:PacketChannel.java   
public void sendToAll(AbstractPacket message)
{
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
    channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
项目:iChunUtil    文件:PacketChannel.java   
public void sendTo(AbstractPacket message, EntityPlayer player)
{
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
    channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
项目:iChunUtil    文件:PacketChannel.java   
public void sendToAllAround(AbstractPacket message, TargetPoint point)
{
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
    channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
项目:iChunUtil    文件:PacketChannel.java   
public void sendToDimension(AbstractPacket message, int dimensionId)
{
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
    channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
    channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}