@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); }
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(); }
@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); } }
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(); } }
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()); }
@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); } }
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); }
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); }
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 ); }
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 ); }
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 ); }
@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 ); }
@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); } }); }
@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); } }
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); }
public static void sendPacketToAllPlayers(FFSPacket packet) { FMLEmbeddedChannel channel = channels.get(Side.SERVER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); channel.writeOutbound(packet); }
public static void sendPacketToServer(FFSPacket packet) { FMLEmbeddedChannel channel = channels.get(Side.CLIENT); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); channel.writeOutbound(packet); }
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); }
/** * @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); }
/** * @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); }
/** * 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); }
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); }
@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); }
public void sendToServer(SasaPacketBase packet) { channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); channels.get(Side.CLIENT).writeOutbound(packet); }
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); }
public void sendToAll(SasaPacketBase packet) { channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); channels.get(Side.SERVER).writeOutbound(packet); }
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); }
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); }
public void sendToAll( Packet packet ) { Channel channel = channels.get( Side.SERVER ); channel.attr( FMLOutboundHandler.FML_MESSAGETARGET ).set( FMLOutboundHandler.OutboundTarget.ALL ); channel.writeAndFlush( packet ); }
public void sendToServer(RLMPacketBase packet) { channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET) .set(FMLOutboundHandler.OutboundTarget.TOSERVER); channels.get(Side.CLIENT).writeAndFlush(packet); }
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); }
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); }
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); }
@Override protected void configureChannel(Channel channel) { channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(selector); }
@Override protected void configureChannel(Channel channel, T target) { channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(selector); channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(target); }
@Override protected void configureChannel(Channel channel, T target) { channel.attr(ExtendedOutboundHandler.MESSAGETARGET).set(selector); channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(target); }
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); }
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); }
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); }
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); }