当前位置: 首页>>代码示例>>Java>>正文


Java FMLProxyPacket.payload方法代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.network.internal.FMLProxyPacket.payload方法的典型用法代码示例。如果您正苦于以下问题:Java FMLProxyPacket.payload方法的具体用法?Java FMLProxyPacket.payload怎么用?Java FMLProxyPacket.payload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fml.common.network.internal.FMLProxyPacket的用法示例。


在下文中一共展示了FMLProxyPacket.payload方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPacketData

import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
public void onPacketData(
		final FMLProxyPacket packet,
		final INetHandler handler,
		final EntityPlayerMP playerEntity )
{
	if ( playerEntity == null )
	{
		return;
	}

	final PacketBuffer buffer = new PacketBuffer( packet.payload() );
	final ModPacket innerPacket = parsePacket( buffer );
	innerPacket.serverEntity = playerEntity;

	PacketThreadUtil.checkThreadAndEnqueue( innerPacket, handler, playerEntity.getServer() );
	innerPacket.server( playerEntity );
}
 
开发者ID:AlgorithmX2,项目名称:Ambidextrous,代码行数:19,代码来源:NetworkRouter.java

示例2: decode

import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
    ByteBuf buf = msg.payload();
    int packetId = buf.readByte();
    Class pktCls = packets.get(packetId);
    SasaPacketBase pkt = (SasaPacketBase)pktCls.newInstance();
    pkt.fromByteBuf(ctx, buf);
    if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
    {
        pkt.receiveClient(getClientPlayer());
    }
    else if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
    {
        INetHandler localINetHandler = (INetHandler)ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
        EntityPlayer ep = ((NetHandlerPlayServer)localINetHandler).playerEntity;
        pkt.receiveServer(ep);
    }
}
 
开发者ID:noto0648,项目名称:SasaLib,代码行数:20,代码来源:PacketDispatcher.java

示例3: decode

import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
	ByteBuf packetPayload = msg.payload();
	byte indexOfClass = packetPayload.readByte();
	ByteBufInputStream bbis = new ByteBufInputStream(packetPayload.slice());
	Class<? extends CLLPacket> packetClass = registeredPackets.get(indexOfClass);
	if(packetClass != null){
		CLLPacket packetCLL = packetClass.newInstance();
		packetCLL.readDataFrom(bbis);
		switch(FMLCommonHandler.instance().getEffectiveSide()){
		case CLIENT:
			handleClient(packetCLL);
			break;
		case SERVER:
			packetCLL.handleServerSide(((NetHandlerPlayServer)ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()).player);
			break;			
		}
		bbis.close();
		out.add(packetCLL);
	}
}
 
开发者ID:Phlenum,项目名称:Combustible-Lemon-Launcher,代码行数:22,代码来源:CLLPacketHandler.java

示例4: decode

import net.minecraftforge.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 ARKMessage> clazz = packets.get(discriminator);
	if (clazz == null) { throw new NullPointerException("No packet registered for discriminator: "
			+ discriminator); }

	ARKMessage 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:BubbleTrouble14,项目名称:ARKCraft,代码行数:32,代码来源:ARKMessagePipeline.java

示例5: decode

import net.minecraftforge.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("No packet registered for discriminator: " + discriminator);
	}

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

	EntityPlayer player;
	switch (FMLCommonHandler.instance().getEffectiveSide())
	{
	case CLIENT:
		player = this.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:
	}
}
 
开发者ID:tyronx,项目名称:vintagetg,代码行数:32,代码来源:PacketPipeline.java

示例6: decode

import net.minecraftforge.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 PacketAbstract> clazz = this.packets.get(discriminator);
    if (clazz == null) {
        throw new NullPointerException(
                "No packet registered for discriminator: " + discriminator);
    }
    PacketAbstract pkt = clazz.newInstance();
    pkt.decodeInto(ctx, payload.slice());
    EntityPlayer player;
    switch (FMLCommonHandler.instance().getEffectiveSide()) {
        case CLIENT:
            player = this.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:Dark32,项目名称:NordMod,代码行数:29,代码来源:PacketPipeline.java

示例7: decode

import net.minecraftforge.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 ARKMessage> clazz = packets.get(discriminator);
    if (clazz == null)
    {
        throw new NullPointerException("No packet registered for discriminator: " + discriminator);
    }

    ARKMessage 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:Archiving,项目名称:ARKCraft-Code,代码行数:34,代码来源:ARKMessagePipeline.java

示例8: decode

import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
    PacketBuffer payload = new PacketBuffer(msg.payload());
    Packet packet = new AchSyncPacket();
    packet.readPacketData(payload);
    packet.processPacket(null);
}
 
开发者ID:killjoy1221,项目名称:Achievement-Get,代码行数:8,代码来源:AchievementChannel.java

示例9: decode

import net.minecraftforge.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 Packet> packetClass = this.packets.get(discriminator);
	if (packetClass == null)
	{
		throw new NullPointerException("No packet registered for discriminator: " + discriminator);
	}

	Packet pkt = packetClass.newInstance();
	pkt.decode(ctx, payload.slice());

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

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

	default:
	}

	out.add(pkt);
}
 
开发者ID:andykuo1,项目名称:mcplus_mods,代码行数:34,代码来源:PacketChannel.java

示例10: decode

import net.minecraftforge.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("No packet registered for discriminator: " + discriminator);
    }

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

    EntityPlayer player;
    switch (FMLCommonHandler.instance().getEffectiveSide()) {
        case CLIENT:
            player = this.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:mickelus,项目名称:customgen,代码行数:31,代码来源:PacketPipeline.java

示例11: decode

import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
	final PacketBuffer input = new PacketBuffer(msg.payload());

	final Side side = ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get();

	final IRpcTarget target;
	final MethodEntry method;
	final Object[] args;

	{
		final int targetId = input.readVarInt();
		final BiMap<Integer, TargetTypeProvider> idToEntryMap = CommonRegistryCallbacks.getEntryIdMap(targetRegistry).inverse();
		final TargetTypeProvider entry = idToEntryMap.get(targetId);
		target = entry.createRpcTarget();
		EntityPlayer player = getPlayer(msg);
		target.readFromStreamStream(side, player, input);
	}

	{
		final BiMap<MethodEntry, Integer> eventIdMap = CommonRegistryCallbacks.getEntryIdMap(methodRegistry);
		final int methodId = input.readVarInt();
		method = eventIdMap.inverse().get(methodId);
		args = method.paramsCodec.readArgs(input);
	}

	int bufferJunkSize = input.readableBytes();
	Preconditions.checkState(bufferJunkSize == 0, "%s junk bytes left in buffer, method = %s", bufferJunkSize, method);

	out.add(new RpcCall(target, method, args));
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:32,代码来源:RpcCallCodec.java

示例12: decode

import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
	final Channel channel = ctx.channel();
	final Side side = channel.attr(NetworkRegistry.CHANNEL_SOURCE).get();

	final PacketBuffer payload = new PacketBuffer(msg.payload());
	final int typeId = payload.readVarInt();
	final NetworkEventEntry type = CommonRegistryCallbacks.getEntryIdMap(registry).inverse().get(typeId);

	final EventDirection validator = type.getDirection();
	Preconditions.checkState(validator != null && validator.validateReceive(side),
			"Invalid direction: receiving packet %s on side %s", msg.getClass(), side);

	final NetworkEvent event = type.createPacket();
	event.readFromStream(payload);
	event.dispatcher = msg.getDispatcher();

	event.side = side;

	final INetHandler handler = msg.handler();
	if (handler != null) event.sender = OpenMods.proxy.getPlayerFromHandler(handler);

	final int bufferJunkSize = payload.readableBytes();
	if (bufferJunkSize > 0) Log.warn("%s junk bytes left in buffer, event %s", bufferJunkSize, event);

	out.add(event);
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:28,代码来源:NetworkEventCodec.java


注:本文中的net.minecraftforge.fml.common.network.internal.FMLProxyPacket.payload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。