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


Java FMLProxyPacket.payload方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket packet) throws Exception
{
    if (packet.channel().equals(TheMod.RESOURCE_PREFIX + "Network"))
    {
        ByteBuf payload = packet.payload();
        final PacketBuffer packetBuffer = new PacketBuffer(payload);
        final PacketType[] values = PacketType.values();
        final int packetTypeValue = packetBuffer.readInt();
        if (packetTypeValue >= values.length)
        {
            Logger.warning("Unknown Packet type: %d", packetTypeValue);
            return;
        }

        PacketType packetType = values[packetTypeValue];
        switch (packetType)
        {
            case SET_SCHEMATIC_NAME:
                setSchematicName(packetBuffer);
                break;
        }
    }
}
 
開發者ID:AtomicBlom,項目名稱:SchematicMetaBlocks,代碼行數:25,代碼來源:PacketHandler.java

示例4: decode

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
    ByteBuf payload = msg.payload();
    byte discriminator = payload.readByte();
    Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);

    AbstractPacket pkt = clazz.newInstance();
    pkt.decodeInto(ctx, payload.slice());

    switch (FMLCommonHandler.instance().getEffectiveSide()) {
        case CLIENT:
            pkt.handleClientSide(this.getClientPlayer());
            break;
        case SERVER:
            INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
            pkt.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity);
            break;
        default:
        	break;
    }

    out.add(pkt);
}
 
開發者ID:DavidGoldman,項目名稱:NBTEdit,代碼行數:24,代碼來源:PacketPipeline.java

示例5: onFMLProxyPacketData

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
public void onFMLProxyPacketData(NetworkManager manager, FMLProxyPacket packet, EntityPlayer player)
{
	try {
		if ((packet == null) || (packet.payload() == null)) throw new RuntimeException("Empty packet sent to Galacticraft channel");
		ByteBuf data = packet.payload();
		this.handle(data, player);
	} catch (Exception e) {
		GCLog.severe("GC login packet handler: Failed to read packet");
		GCLog.severe(e.toString());
		e.printStackTrace();
	}
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:13,代碼來源:ConnectionPacket.java

示例6: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception{
  ByteBuf buf = msg.payload();
  int x = buf.readInt();
  int y = buf.readInt();
  int z = buf.readInt();
  TileEntity te = FCMiner.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
  if(te instanceof GenericTile) {
    ((GenericTile)te).readFromPacket(buf);
  }
}
 
開發者ID:beepbeat,項目名稱:FCMiner,代碼行數:12,代碼來源:DescriptionHandler.java

示例7: decode

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
protected void decode(final ChannelHandlerContext ctx, final FMLProxyPacket msg, final List<Object> out) throws Exception {
    ((ThreadLocal)ctx.attr((AttributeKey)ImaginePacketCodec.PACKET_TRACKER).get()).set(new WeakReference<FMLProxyPacket>(msg));
    final ImaginePacketRegistry packetRegistry = (ImaginePacketRegistry)ctx.attr((AttributeKey)ImaginePacketCodec.PACKET_REGISTRY).get();
    final ByteBuf payload = msg.payload();
    final boolean newPacketClass = payload.readBoolean();
    final int packetClassId = payload.readInt();
    Class<? extends ImaginePacket> packetClass;
    if (newPacketClass) {
        final int classNameLength = payload.readInt();
        if (classNameLength <= 0) {
            new IllegalArgumentException("Too short class name: " + classNameLength).printStackTrace();
            ctx.close();
        }
        if (classNameLength > 1024) {
            new IllegalArgumentException("Too long class name: " + classNameLength).printStackTrace();
            ctx.close();
        }
        final byte[] classNameBytes = new byte[classNameLength];
        payload.readBytes(classNameBytes, 0, classNameLength);
        final String className = new String(classNameBytes, 0, classNameLength, ImaginePacketCodec.UTF_8);
        packetClass = (Class<? extends ImaginePacket>)Class.forName(className);
        if (!ImaginePacket.class.isAssignableFrom(packetClass)) {
            new IllegalArgumentException("Provided class isn't imagine packet: " + packetClass).printStackTrace();
            ctx.close();
        }
        packetRegistry.register(packetClassId, packetClass);
    }
    else {
        packetClass = packetRegistry.get(packetClassId);
    }
    if (packetClass == null) {
        new NullPointerException("Undefined message in channel " + msg.channel()).printStackTrace();
        ctx.close();
    }
    final ImaginePacket packet = ImagineNetwork.obtainPacket(packetClass);
    packet.readPacket(ctx, new WritableBuf(payload.slice()));
    out.add(packet);
}
 
開發者ID:CyberdyneCC,項目名稱:ThermosRebased,代碼行數:39,代碼來源:ImaginePacketCodec.java

示例8: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception
{
    ByteBuf buf = msg.payload();
    int x = buf.readInt();
    int y = buf.readInt();
    int z = buf.readInt();
    TileEntity te = Network.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
    if (te instanceof TileEntityNetwork)
    {
        ((TileEntityNetwork) te).readFromPacket(buf);
    }
}
 
開發者ID:samvbeckmann,項目名稱:network,代碼行數:14,代碼來源:DescriptionHandler.java

示例9: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception{
    ByteBuf buf = msg.payload();
    int x = buf.readInt();
    int y = buf.readInt();
    int z = buf.readInt();
    TileEntity te = RainbowElectricity.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
    if(te instanceof TileEntityRainbowElectricity) {
        ((TileEntityRainbowElectricity)te).readFromPacket(buf);
    }
}
 
開發者ID:nikita488,項目名稱:RainbowElectricity,代碼行數:12,代碼來源:DescriptionHandler.java

示例10: onFMLProxyPacketData

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
public void onFMLProxyPacketData(NetworkManager manager, FMLProxyPacket packet, EntityPlayer player)
{
    try {
        if ((packet == null) || (packet.payload() == null)) throw new RuntimeException("Empty packet sent to Amunra channel");
        ByteBuf data = packet.payload();
        this.handle(data, player);
    } catch (Exception e) {
        GCLog.severe("Amunra login packet handler: Failed to read packet");
        GCLog.severe(e.toString());
        e.printStackTrace();
    }
}
 
開發者ID:katzenpapst,項目名稱:amunra,代碼行數:13,代碼來源:ConnectionPacketAR.java

示例11: decode

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
    ByteBuf payload = msg.payload();
    byte discriminator = payload.readByte();
    Class<? extends MMMessage> clazz = packets.get(discriminator);
    if (clazz == null) {
        throw new NullPointerException("No packet registered for discriminator: " + discriminator);
    }

    MMMessage pkt = clazz.newInstance();
    pkt.decodeInto(ctx, payload.slice());

    EntityPlayer player;
    switch (FMLCommonHandler.instance().getEffectiveSide()) {
        case CLIENT:
            player = getClientPlayer();
            pkt.handleClientSide(player);
            break;

        case SERVER:
            INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
            player = ((NetHandlerPlayServer) netHandler).playerEntity;
            pkt.handleServerSide(player);
            break;

        default:
    }

    out.add(pkt);
}
 
開發者ID:MHuanterAxe,項目名稱:MHuanterMod,代碼行數:31,代碼來源:MMMessagePipeline.java

示例12: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception {
    World world = DynamicLib.proxy.getClientWorld();

    ByteBuf payload = msg.payload();
    DataInputStream input = new DataInputStream(new ByteBufInputStream(payload));

    ISyncMapProvider provider = SyncMap.findSyncMap(world, input);
    try {
        if (provider != null) provider.getSyncMap().readFromStream(input);
    } catch (Throwable e) {
        throw new SyncException(e, provider);
    }
}
 
開發者ID:awesommist,項目名稱:DynamicLib,代碼行數:15,代碼來源:InboundSyncHandler.java

示例13: decode

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

示例14: decode

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
	ByteBuf payload = msg.payload();
	byte discriminator = payload.readByte();

	Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);
	if (clazz == null) {
		throw new NullPointerException("This packet has never been registered" + clazz.getCanonicalName());

	}
	AbstractPacket abstractPacket = clazz.newInstance();
	abstractPacket.decodeInto(ctx, payload.slice());

	EntityPlayer player;
	switch (FMLCommonHandler.instance().getEffectiveSide()) {
	case CLIENT:
		player = this.getClientPlayer();
		abstractPacket.handleClientSide(player);
		break;
	case SERVER:
		INetHandler iNetHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
		player = ((NetHandlerPlayServer) iNetHandler).playerEntity;
		abstractPacket.handleServerSide(player);
		break;
	default:
	}
	//out.add(abstractPacket);
}
 
開發者ID:TheDarkEra,項目名稱:TheDarkEra,代碼行數:29,代碼來源:PacketPipeline.java

示例15: channelRead0

import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception{
	ByteBuf buf = msg.payload();
	int x = buf.readInt();
	int y = buf.readInt();
	int z = buf.readInt();
	TileEntity te = RandomThoughtsMod.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
	if(te instanceof TileEntity_RandomThoughtsMod) {
		((TileEntity_RandomThoughtsMod)te).readFromPacket(buf);
	}
}
 
開發者ID:archmon,項目名稱:RandomThoughtsMod,代碼行數:12,代碼來源:DescriptionHandler.java


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