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

项目: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    文件:NetworkRegistry.java   
/**
 * INTERNAL fire a handshake to all channels
 * @param networkDispatcher The dispatcher firing
 * @param origin which side the dispatcher is on
 */
public void fireNetworkHandshake(NetworkDispatcher networkDispatcher, Side origin)
{
    NetworkHandshakeEstablished handshake = new NetworkHandshakeEstablished(networkDispatcher, networkDispatcher.getNetHandler(), origin);
    for (Entry<String, FMLEmbeddedChannel> channel : channels.get(origin).entrySet())
    {
        channel.getValue().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.DISPATCHER);
        channel.getValue().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(networkDispatcher);
        channel.getValue().pipeline().fireUserEventTriggered(handshake);
    }
}
项目: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());
}
项目: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);
        }
    });
}
项目: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);
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
public static ITargetedPacketSender<EntityPlayer> createPlayerSender(Channel channel) {
    return new FmlTargetedPacketSender<>(channel, OutboundTarget.PLAYER);
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
public static ITargetedPacketSender<Integer> createDimensionSender(Channel channel) {
    return new FmlTargetedPacketSender<>(channel, OutboundTarget.DIMENSION);
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
public static ITargetedPacketSender<TargetPoint> createPointSender(Channel channel) {
    return new FmlTargetedPacketSender<>(channel, OutboundTarget.ALLAROUNDPOINT);
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
public static IPacketSender createSender(Channel channel, OutboundTarget target) {
    return new FmlPacketSender(channel, target);
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
public FmlPacketSender(Channel channel, OutboundTarget selector) {
    super(channel);
    this.selector = selector;
}
项目:OpenModsLib    文件:FmlPacketSenderFactory.java   
public FmlTargetedPacketSender(Channel channel, OutboundTarget selector) {
    super(channel);
    this.selector = selector;
}
项目:CustomWorldGen    文件:FMLEmbeddedChannel.java   
/**
 * Utility method to generate a regular packet from a custom packet. Basically, it writes the packet through the
 * outbound side which should have a message to message codec present (such as {@link FMLIndexedMessageToMessageCodec},
 * transforming from mod packets to standard {@link FMLProxyPacket}s.
 *
 * This is mostly useful in cases where vanilla expects a packet, such as the TileEntity getDescriptionPacket.
 *
 * @param object The inbound packet
 * @return A Packet suitable for passing to vanilla network code.
 */
public Packet<?> generatePacketFrom(Object object)
{
    OutboundTarget outboundTarget = attr(FMLOutboundHandler.FML_MESSAGETARGET).getAndSet(OutboundTarget.NOWHERE);
    writeOutbound(object);
    Packet<?> pkt = (Packet<?>) outboundMessages().poll();
    attr(FMLOutboundHandler.FML_MESSAGETARGET).set(outboundTarget);
    return pkt;
}