/**
* Utility method to generate a regular packet from a custom packet. Basically, it writes the packet through the
* outbound side which should have a message to message codec present (such as {@link FMLIndexedMessageToMessageCodec},
* transforming from mod packets to standard {@link FMLProxyPacket}s.
*
* This is mostly useful in cases where vanilla expects a packet, such as the TileEntity getDescriptionPacket.
*
* @param object The inbound packet
* @return A Packet suitable for passing to vanilla network code.
*/
public Packet<?> generatePacketFrom(Object object)
{
OutboundTarget outboundTarget = attr(FMLOutboundHandler.FML_MESSAGETARGET).getAndSet(OutboundTarget.NOWHERE);
writeOutbound(object);
Packet<?> pkt = (Packet<?>) outboundMessages().poll();
attr(FMLOutboundHandler.FML_MESSAGETARGET).set(outboundTarget);
return pkt;
}
FMLEmbeddedChannel.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:CustomWorldGen
作者:
评论列表
文章目录