public static void makeEntitySpawnAdjustment(Entity entity, EntityPlayerMP player, int serverX, int serverY, int serverZ) { EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER); embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); embeddedChannel.writeOutbound(new FMLMessage.EntityAdjustMessage(entity, serverX, serverY, serverZ)); }
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(); } }
/** * 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); } }
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()); }
public void sendToPlayer(IPacket par1, EntityPlayer par2) { channel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); channel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(par2); channel.get(Side.SERVER).writeOutbound(par1); }
public void sendToServer(IPacket par1) { channel.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER); channel.get(Side.CLIENT).writeOutbound(par1); }
public void sendToAllPlayers(EQMessage message) { channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.ALL); channels.get(Side.SERVER).writeOutbound(message); }
public void sendToAllPlayersInDimension(int dimensionID, EQMessage message) { channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.DIMENSION); channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionID); channels.get(Side.SERVER).writeOutbound(message); }
public void sendToAllPlayersAround(TargetPoint point, EQMessage message) { channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.ALLAROUNDPOINT); channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); channels.get(Side.SERVER).writeOutbound(message); }
public void sendToPlayer(EntityPlayer player, EQMessage message) { channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER); channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); channels.get(Side.SERVER).writeOutbound(message); }
public void sendToServer(EQMessage message) { channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER); channels.get(Side.CLIENT).writeOutbound(message); }
/** * 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; }