本文整理汇总了Java中net.minecraftforge.fml.common.network.internal.FMLProxyPacket.setDispatcher方法的典型用法代码示例。如果您正苦于以下问题:Java FMLProxyPacket.setDispatcher方法的具体用法?Java FMLProxyPacket.setDispatcher怎么用?Java FMLProxyPacket.setDispatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fml.common.network.internal.FMLProxyPacket
的用法示例。
在下文中一共展示了FMLProxyPacket.setDispatcher方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encode
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected final void encode(ChannelHandlerContext ctx, A msg, List<Object> out) throws Exception
{
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
byte discriminator = types.get(msg.getClass());
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);
}
示例2: encode
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, NetworkEvent msg, List<Object> out) throws IOException {
final Channel channel = ctx.channel();
final Side side = channel.attr(NetworkRegistry.CHANNEL_SOURCE).get();
final NetworkEventEntry entry = CommonRegistryCallbacks.getObjectToEntryMap(registry).get(msg.getClass());
Preconditions.checkState(entry != null, "Can't find registration for class %s", msg.getClass());
final int id = CommonRegistryCallbacks.getEntryIdMap(registry).get(entry);
final EventDirection validator = entry.getDirection();
Preconditions.checkState(validator != null && validator.validateSend(side),
"Invalid direction: sending packet %s on side %s", msg.getClass(), side);
final PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
buf.writeVarInt(id);
msg.writeToStream(buf);
final FMLProxyPacket packet = new FMLProxyPacket(buf, NetworkEventDispatcher.CHANNEL_NAME);
packet.setDispatcher(msg.dispatcher);
out.add(packet);
}
示例3: queueUnwrappedPacket
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
public boolean queueUnwrappedPacket(EntityPlayer player, Object packetObj) {
if (packetObj == null) return true;
if (player == null) {
if (packetObj instanceof C00PacketKeepAlive || packetObj instanceof S00PacketKeepAlive) {
NORELEASE.fixme("Shouldn't this, like, not happen?");
return true;
}
NORELEASE.println("No player to handle: " + packetObj + " " + packetObj.getClass().getSimpleName());
return true;
}
if (player.worldObj.isRemote) return false;
Packet packet = (Packet) packetObj;
// May possibly need to inject the liason into things up higher, during reading. Somehow. Hopefulloy won't be needed.
InteractionLiason liason = InteractionLiason.activeLiasons.get(player);
if (liason == null) {
if (!(packet instanceof C00PacketKeepAlive)) {
// Seems our system isn't perfect. :/
// Keepalives are generated from a different thread I guess.
Hammer.logWarning("Liasonless wrapped packet: " + packet.getClass().getSimpleName() + " " + packet.toString());
}
return true;
}
NetHandlerPlayServer handler = liason.playerNetServerHandler;
if (packet instanceof FMLProxyPacket) {
FMLProxyPacket fml = (FMLProxyPacket) packet;
NetworkDispatcher dispatcher = handler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
fml.setTarget(Side.CLIENT);
fml.setDispatcher(dispatcher);
if (fml.payload().readerIndex() != 0) {
Core.logSevere("Packet double-processing detected! Channel: " + fml.channel());
return true;
}
}
packet.processPacket(handler);
return true;
}