當前位置: 首頁>>代碼示例>>Java>>正文


Java FMLOutboundHandler類代碼示例

本文整理匯總了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();
        }
    }
}
 
開發者ID:Dynious,項目名稱:SoundsCool,代碼行數:26,代碼來源:TileSoundPlayer.java

示例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));
    }
}
 
開發者ID:KJ4IPS,項目名稱:Hackery,代碼行數:22,代碼來源:nsodCommand.java

示例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;
        }
    }
 
開發者ID:Cazzar,項目名稱:VoxelPlayerModels,代碼行數:25,代碼來源:ClientDataPacket.java

示例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 });
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:10,代碼來源:NetworkHandler.java

示例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();
	}
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:24,代碼來源:GalacticraftChannelHandler.java

示例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();
	}
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:22,代碼來源:GalacticraftChannelHandler.java

示例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();
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:9,代碼來源:NetworkDispatcher.java

示例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);
    }
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:13,代碼來源:SimpleChannelHandlerWrapper.java

示例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));
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:8,代碼來源:FMLNetworkHandler.java

示例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();
    }
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:12,代碼來源:FMLNetworkHandler.java

示例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());
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:14,代碼來源:ForgeNetworkHandler.java

示例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);
    }

}
 
開發者ID:awesommist,項目名稱:DynamicLib,代碼行數:41,代碼來源:ExtendedOutboundHandler.java

示例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;
    }
}
 
開發者ID:Dynious,項目名稱:SoundsCool,代碼行數:11,代碼來源:TileSoundPlayer.java

示例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);
        }
    }
 
開發者ID:tm1990,項目名稱:MiscUtils,代碼行數:13,代碼來源:PacketHandler.java

示例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);
        }
    }
 
開發者ID:tm1990,項目名稱:MiscUtils,代碼行數:10,代碼來源:PacketHandler.java


注:本文中的cpw.mods.fml.common.network.FMLOutboundHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。