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


Java FMLProxyPacket.handler方法代码示例

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


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

示例1: make

import net.minecraftforge.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.getNetworkManager(), msg);
    }
    return event;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:FMLEventChannel.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 {
	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

示例3: getPlayer

import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
protected EntityPlayer getPlayer(FMLProxyPacket msg) {
	INetHandler handler = msg.handler();
	EntityPlayer player = OpenMods.proxy.getPlayerFromHandler(handler);
	Preconditions.checkNotNull(player, "Can't get player from handler %s", handler);
	return player;
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:7,代码来源:RpcCallCodec.java


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