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


Java FMLProxyPacket類代碼示例

本文整理匯總了Java中cpw.mods.fml.common.network.internal.FMLProxyPacket的典型用法代碼示例。如果您正苦於以下問題:Java FMLProxyPacket類的具體用法?Java FMLProxyPacket怎麽用?Java FMLProxyPacket使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FMLProxyPacket類屬於cpw.mods.fml.common.network.internal包,在下文中一共展示了FMLProxyPacket類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: splitPacket

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
public static List<XUPacketSplit> splitPacket(final FMLProxyPacket packet) {
    final List<XUPacketSplit> out = new ArrayList<XUPacketSplit>();
    final ByteBuf buf = packet.payload().copy();
    int n = buf.readableBytes() / 2007136;
    if (n * 2007136 < buf.readableBytes()) {
        ++n;
    }
    ++PacketSplitter.curSendingIndex;
    LogHelper.debug("Splitting packet to " + n + " packets", new Object[0]);
    for (int i = 0; i < n; ++i) {
        final int s = (buf.readableBytes() < 2007136) ? buf.readableBytes() : 2007136;
        final ByteBuf o = Unpooled.buffer(s);
        buf.readBytes(o, s);
        out.add(new XUPacketSplit(buf, PacketSplitter.curSendingIndex, i, n));
    }
    return out;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:18,代碼來源:PacketSplitter.java

示例2: make

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@Override
FMLNetworkEvent.CustomPacketEvent<?> make(FMLProxyPacket msg)
{
    FMLNetworkEvent.CustomPacketEvent<?> event = null;
    if (msg.handler() instanceof NetHandlerPlayClient)
    {
        NetHandlerPlayClient client = (NetHandlerPlayClient) msg.handler();
        event = new FMLNetworkEvent.ClientCustomPacketEvent(client.func_147298_b(), msg);
    }
    else if (msg.handler() instanceof NetHandlerPlayServer)
    {
        NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler();
        event = new FMLNetworkEvent.ServerCustomPacketEvent(server.func_147362_b(), msg);
    }
    return event;
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:17,代碼來源:FMLEventChannel.java

示例3: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception
{
    Side side = msg.getTarget();
    NetworkManager manager = msg.getOrigin();
    if (msg.channel().equals("REGISTER") || msg.channel().equals("UNREGISTER"))
    {
        byte[] data = new byte[msg.payload().readableBytes()];
        msg.payload().readBytes(data);
        String channels = new String(data,Charsets.UTF_8);
        String[] split = channels.split("\0");
        Set<String> channelSet = ImmutableSet.copyOf(split);
        FMLCommonHandler.instance().fireNetRegistrationEvent(manager, channelSet, msg.channel(), side);
    }
    else
    {
        ctx.fireChannelRead(msg);
    }
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:20,代碼來源:ChannelRegistrationHandler.java

示例4: selectNetworks

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet)
{
    int dimension = (Integer)args;
    ImmutableList.Builder<NetworkDispatcher> builder = ImmutableList.<NetworkDispatcher>builder();
    for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().func_71203_ab().field_72404_b)
    {
        if (dimension == player.field_71093_bK)
        {
            NetworkDispatcher dispatcher = player.field_71135_a.field_147371_a.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
            // Null dispatchers may exist for fake players - skip them
            if (dispatcher != null) builder.add(dispatcher);
        }
    }
    return builder.build();
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:18,代碼來源:FMLOutboundHandler.java

示例5: encode

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@Override
protected final void encode(ChannelHandlerContext ctx, A msg, List<Object> out) throws Exception
{
    ByteBuf buffer = Unpooled.buffer();
    @SuppressWarnings("unchecked") // Stupid unnecessary cast I can't seem to kill
    Class<? extends A> clazz = (Class<? extends A>) msg.getClass();
    byte discriminator = types.get(clazz);
    buffer.writeByte(discriminator);
    encodeInto(ctx, msg, buffer);
    FMLProxyPacket proxy = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
    WeakReference<FMLProxyPacket> ref = ctx.attr(INBOUNDPACKETTRACKER).get().get();
    FMLProxyPacket old = ref == null ? null : ref.get();
    if (old != null)
    {
        proxy.setDispatcher(old.getDispatcher());
    }
    out.add(proxy);
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:19,代碼來源:FMLIndexedMessageToMessageCodec.java

示例6: decode

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@Override
protected final void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
    testMessageValidity(msg);
    ByteBuf payload = msg.payload();
    byte discriminator = payload.readByte();
    Class<? extends A> clazz = discriminators.get(discriminator);
    if(clazz == null)
    {
        throw new NullPointerException("Undefined message for discriminator " + discriminator + " in channel " + msg.channel());
    }
    A newMsg = clazz.newInstance();
    ctx.attr(INBOUNDPACKETTRACKER).get().set(new WeakReference<FMLProxyPacket>(msg));
    decodeInto(ctx, payload.slice(), newMsg);
    out.add(newMsg);
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:17,代碼來源:FMLIndexedMessageToMessageCodec.java

示例7: handlePacket

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
protected void handlePacket(FMLProxyPacket proxyPacket, EntityPlayerMP player) {
	final ByteBuf payload = proxyPacket.payload();
	if( payload.readableBytes() > 0 ) {
		final PacketBuffer buf = new PacketBuffer(payload);
		
		final byte id = buf.readByte();
		final PacketType type = PacketType.get(id);
		if( type == null ) {
			FairyFactions.LOGGER.error("Got unknown packet type "+id);
			return;
		}
		
		final FairyPacket packet;
		try {
			packet = type.packet_class.newInstance();
		} catch (Exception e) {
			// ERROR, unable to actually process
			e.printStackTrace();
			return;
		}
		
		packet.init(buf);
		packet.handle(proxyPacket.getOrigin());
	}
}
 
開發者ID:allaryin,項目名稱:FairyFactions,代碼行數:26,代碼來源:FairyEventListener.java

示例8: createPacket

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
public static FMLProxyPacket createPacket(WorldView worldview) {
	// This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe.
	ByteBuf data = PacketHandlerBase.createDataBuffer((Class<? extends PacketHandlerBase>) new Object() {}.getClass().getEnclosingClass());

	int x = 0;
	int y = -1;
	int z = 0;
	if (worldview.coords != null) {
		x = worldview.coords.posX >> 4;
		y = worldview.coords.posY >> 4;
		z = worldview.coords.posZ >> 4;
	}

	data.writeInt(worldview.getWorldObj().provider.dimensionId);
	data.writeInt(x);
	data.writeInt(y);
	data.writeInt(z);
	data.writeByte(Math.min(ModConfigs.renderDistance, Minecraft.getMinecraft().gameSettings.renderDistanceChunks));

	return buildPacket(data);
}
 
開發者ID:XCompWiz,項目名稱:LookingGlass,代碼行數:23,代碼來源:PacketCreateView.java

示例9: make

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@Override
FMLNetworkEvent.CustomPacketEvent<?> make(FMLProxyPacket msg)
{
    FMLNetworkEvent.CustomPacketEvent<?> event = null;
    if (msg.handler() instanceof NetHandlerPlayClient)
    {
        NetHandlerPlayClient client = (NetHandlerPlayClient) msg.handler();
        event = new FMLNetworkEvent.ClientCustomPacketEvent(client.getNetworkManager(), msg);
    }
    else if (msg.handler() instanceof NetHandlerPlayServer)
    {
        NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler();
        event = new FMLNetworkEvent.ServerCustomPacketEvent(server.func_147362_b(), msg);
    }
    return event;
}
 
開發者ID:alexandrage,項目名稱:CauldronGit,代碼行數:17,代碼來源:FMLEventChannel.java

示例10: selectNetworks

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet)
{
    int dimension = (Integer)args;
    ImmutableList.Builder<NetworkDispatcher> builder = ImmutableList.<NetworkDispatcher>builder();
    for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList)
    {
        if (dimension == player.dimension)
        {
            NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
            // Null dispatchers may exist for fake players - skip them
            if (dispatcher != null) builder.add(dispatcher);
        }
    }
    return builder.build();
}
 
開發者ID:alexandrage,項目名稱:CauldronGit,代碼行數:18,代碼來源:FMLOutboundHandler.java

示例11: createConfigPacket

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
public static FMLProxyPacket createConfigPacket()
{
    ByteBuf payload = Unpooled.buffer();

    payload.writeByte(ID_CONFIG_OVERRIDE);

    NBTTagCompound nbt = AmunRa.config.getServerOverrideData();

    try {
        NetworkUtil.writeNBTTagCompound(nbt, payload);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return new FMLProxyPacket(payload, CHANNEL);
}
 
開發者ID:katzenpapst,項目名稱:amunra,代碼行數:17,代碼來源:ConnectionPacketAR.java

示例12: createMothershipPacket

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
public static FMLProxyPacket createMothershipPacket()
{
    ByteBuf payload = Unpooled.buffer();

    payload.writeByte(ID_MOTHERSHIP_LIST);

    NBTTagCompound nbt = new NBTTagCompound ();
    TickHandlerServer.mothershipData.writeToNBT(nbt);

    try {
        NetworkUtil.writeNBTTagCompound(nbt, payload);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return new FMLProxyPacket(payload, CHANNEL);
}
 
開發者ID:katzenpapst,項目名稱:amunra,代碼行數:18,代碼來源:ConnectionPacketAR.java

示例13: encode

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@Override
protected void encode (ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception
{
	ByteBuf buffer = Unpooled.buffer();
	Class<? extends AbstractPacket> clazz = msg.getClass();
	if (!this.packets.contains(msg.getClass()))
	{
		throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName());
	}

	byte discriminator = (byte) this.packets.indexOf(clazz);
	buffer.writeByte(discriminator);
	msg.encodeInto(ctx, buffer);
	FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
	out.add(proxyPacket);
}
 
開發者ID:Deadrik,項目名稱:StellarForge,代碼行數:17,代碼來源:PacketPipeline.java

示例14: removeCorruptionEffectForPlayer

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
public static void removeCorruptionEffectForPlayer(EntityPlayer entityPlayer, String name) {
    NBTTagCompound corruptionData = getCorruptionDataForPlayer(entityPlayer);
    NBTTagList corrEffects = corruptionData.getTagList("CorruptionEffects", 8);
    if (corrEffects != null && corrEffects.tagCount() > 0) {
        NBTTagList copy = (NBTTagList) corrEffects.copy();
        for (int i = 0; i < copy.tagCount(); i++) {
            if (name.equals(copy.getStringTagAt(i))) {
                corrEffects.removeTag(i);
                break;
            }
        }
    }
    corruptionData.setTag("CorruptionEffects", corrEffects);

    FMLProxyPacket packet = PacketEventHandler.getCorruptionEffectPacket(entityPlayer.getCommandSenderName(), name, false, false);
    Corruption.eventChannel.sendToAll(packet);
}
 
開發者ID:kihira,項目名稱:Corruption,代碼行數:18,代碼來源:CorruptionDataHelper.java

示例15: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket packet) throws Exception {
	if(count == 0) first = System.currentTimeMillis();
	count++;
	if(count % 1000 == 0){
		double delta = System.currentTimeMillis() - last;
		last = System.currentTimeMillis();
		if(first != last && delta != 0) System.out.println(count + "packets received. approx " + (1000000D/delta) + "/sec. Avg:" + (count/(last-first)) + "/sec");			
	}
	Side side = FMLCommonHandler.instance().getEffectiveSide();
	if (side == Side.CLIENT) {
		onClientPacketData(packet);
	}
	else {
		onServerPacketData(packet);
	}
}
 
開發者ID:kieranvs,項目名稱:Blockbender,代碼行數:18,代碼來源:NewNetworkHandler.java


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