本文整理匯總了Java中cpw.mods.fml.common.network.FMLOutboundHandler類的典型用法代碼示例。如果您正苦於以下問題:Java FMLOutboundHandler類的具體用法?Java FMLOutboundHandler怎麽用?Java FMLOutboundHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FMLOutboundHandler類屬於cpw.mods.fml.common.network包,在下文中一共展示了FMLOutboundHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playCurrentSound
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
public void playCurrentSound()
{
if (selectedSound != null)
{
if (timeSoundFinishedPlaying < System.currentTimeMillis())
{
if (SoundHandler.getSound(selectedSound.getSoundName()) != null)
{
lastSoundIdentifier = UUID.randomUUID().toString();
SoundsCool.proxy.getChannel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
SoundsCool.proxy.getChannel().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(new NetworkRegistry.TargetPoint(getWorldObj().provider.dimensionId, xCoord, yCoord, zCoord, 64));
SoundsCool.proxy.getChannel().writeOutbound(new ServerPlaySoundPacket(selectedSound.getSoundName(), lastSoundIdentifier, xCoord, yCoord, zCoord));
timeSoundFinishedPlaying = (long)(SoundHelper.getSoundLength(selectedSound.getSoundLocation())*1000) + System.currentTimeMillis();
}
else
{
selectedSound = null;
}
}
else
{
stopCurrentSound();
}
}
}
示例2: processCommand
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
@Override
public void processCommand(ICommandSender plr, String[] args) {
if (!plr.getEntityWorld().isRemote) {
if(args.length != 2){
plr.addChatMessage(new ChatComponentText("commands.nsod.usage"));
return;
}
EntityPlayerMP vicitm = getPlayer(plr,args[0]);
if(vicitm == null){
plr.addChatMessage(new ChatComponentText("commands.nsod.noexist").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
return;
}
Boolean value = Boolean.parseBoolean(args[1]);
if(value == null){
plr.addChatMessage(new ChatComponentText("commands.nsod.usage"));
}
HackeryMod.channel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
HackeryMod.channel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(vicitm);
HackeryMod.channel.get(Side.SERVER).writeAndFlush(new setBSODPacket(value));
}
}
示例3: readBytes
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
@Override
public void readBytes(ByteBuf bytes) {
// System.out.println(String.format("Recieved %s", getClass().getCanonicalName()));
message = Messages.values()[bytes.readInt()];
short len = bytes.readShort();
char[] str = new char[len];
for (short i = 0; i < len; i++) str[i] = bytes.readChar();
sender = new String(str);
switch (message) {
case REQUEST:
for (String player : proxy.playerBodies.keySet()) {
proxy.channel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
proxy.channel.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS)
.set(MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(sender));
proxy.channel.get(Side.SERVER).writeOutbound(new PlayerDataPacket(player));
}
break;
}
}
示例4: sendPacketToPlayer
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
public static void sendPacketToPlayer(final XUPacketBase packet, final EntityPlayer player) {
checkPacket(packet, Side.SERVER);
if (XUHelper.isPlayerFake(player)) {
return;
}
NetworkHandler.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
NetworkHandler.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
NetworkHandler.channels.get(Side.SERVER).writeOutbound(new Object[] { packet });
}
示例5: sendToAllAround
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
/**
* Send this message to everyone within a certain range of a point.
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message The message to send
* @param point The
* {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint}
* around which to send
*/
public void sendToAllAround(IPacket message, NetworkRegistry.TargetPoint point)
{
try {
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
this.channels.get(Side.SERVER).writeOutbound(message);
} catch (Exception e)
{
GCLog.severe("Forge error when sending network packet to nearby players - this is not a Galacticraft bug, does another mod make fake players?");
e.printStackTrace();
}
}
示例6: sendToDimension
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
/**
* Send this message to everyone within the supplied dimension.
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message The message to send
* @param dimensionId The dimension id to target
*/
public void sendToDimension(IPacket message, int dimensionId)
{
try {
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
this.channels.get(Side.SERVER).writeOutbound(message);
} catch (Exception e)
{
GCLog.severe("Forge error when sending network packet to all players in dimension - this is not a Galacticraft bug, does another mod make fake players?");
e.printStackTrace();
}
}
示例7: cleanAttributes
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
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();
}
示例8: channelRead0
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
@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);
}
}
示例9: makeEntitySpawnAdjustment
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
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));
}
示例10: registerChannel
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
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();
}
}
示例11: registerChannel
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
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());
}
示例12: write
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
@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 {
Collection<NetworkDispatcher> dispatchers = Lists.newArrayList();
target.listDispatchers(arg, dispatchers);
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);
}
}
示例13: stopCurrentSound
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
public void stopCurrentSound()
{
if (System.currentTimeMillis() < timeSoundFinishedPlaying)
{
SoundsCool.proxy.getChannel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
SoundsCool.proxy.getChannel().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(new NetworkRegistry.TargetPoint(getWorldObj().provider.dimensionId, xCoord, yCoord, zCoord, 64));
SoundsCool.proxy.getChannel().writeOutbound(new StopSoundPacket(lastSoundIdentifier));
timeSoundFinishedPlaying = 0;
}
}
示例14: SendPacketToPlayerListExcept
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
public static void SendPacketToPlayerListExcept(AbstractPacket packet, EnumMap<Side, FMLEmbeddedChannel> channels, ArrayList<EntityPlayer> list, EntityPlayer pla){
for(EntityPlayer pl : list) {
if(pl.getCommandSenderName().equalsIgnoreCase(pla.getCommandSenderName()))
continue;
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(pl);
channels.get(Side.SERVER).writeAndFlush(packet);
}
}
示例15: SendPacketToPlayerList
import cpw.mods.fml.common.network.FMLOutboundHandler; //導入依賴的package包/類
public static void SendPacketToPlayerList(AbstractPacket packet, EnumMap<Side, FMLEmbeddedChannel> channels, ArrayList<EntityPlayer> list){
for(EntityPlayer pl : list) {
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(pl);
channels.get(Side.SERVER).writeAndFlush(packet);
}
}