本文整理汇总了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;
}
示例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);
}
示例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;
}