本文整理汇总了Java中net.minecraft.network.packet.Packet.getPacketSize方法的典型用法代码示例。如果您正苦于以下问题:Java Packet.getPacketSize方法的具体用法?Java Packet.getPacketSize怎么用?Java Packet.getPacketSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.network.packet.Packet
的用法示例。
在下文中一共展示了Packet.getPacketSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToSendQueue
import net.minecraft.network.packet.Packet; //导入方法依赖的package包/类
/**
* Adds the packet to the correct send queue (chunk data packets go to a separate queue).
*/
public void addToSendQueue(Packet par1Packet)
{
if (!this.isServerTerminating)
{
Object object = this.sendQueueLock;
synchronized (this.sendQueueLock)
{
this.sendQueueByteLength += par1Packet.getPacketSize() + 1;
this.dataPackets.add(par1Packet);
}
}
}
示例2: sendPacket
import net.minecraft.network.packet.Packet; //导入方法依赖的package包/类
/**
* Sends a data packet if there is one to send, or sends a chunk data packet if there is one and the counter is up,
* or does nothing.
*/
private boolean sendPacket()
{
boolean flag = false;
try
{
Packet packet;
int i;
int[] aint;
if (this.field_74468_e == 0 || !this.dataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.dataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e)
{
packet = this.func_74460_a(false);
if (packet != null)
{
Packet.writePacket(packet, this.socketOutputStream);
if (packet instanceof Packet252SharedKey && !this.isOutputEncrypted)
{
if (!this.theNetHandler.isServerHandler())
{
this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey();
}
this.encryptOuputStream();
}
aint = field_74467_d;
i = packet.getPacketId();
aint[i] += packet.getPacketSize() + 1;
flag = true;
}
}
if (this.chunkDataPacketsDelay-- <= 0 && (this.field_74468_e == 0 || !this.chunkDataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.chunkDataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e))
{
packet = this.func_74460_a(true);
if (packet != null)
{
Packet.writePacket(packet, this.socketOutputStream);
aint = field_74467_d;
i = packet.getPacketId();
aint[i] += packet.getPacketSize() + 1;
this.chunkDataPacketsDelay = 0;
flag = true;
}
}
return flag;
}
catch (Exception exception)
{
if (!this.isTerminating)
{
this.onNetworkError(exception);
}
return false;
}
}
示例3: readPacket
import net.minecraft.network.packet.Packet; //导入方法依赖的package包/类
/**
* Reads a single packet from the input stream and adds it to the read queue. If no packet is read, it shuts down
* the network.
*/
private boolean readPacket()
{
boolean flag = false;
try
{
Packet packet = Packet.readPacket(this.tcpConLogAgent, this.socketInputStream, this.theNetHandler.isServerHandler(), this.networkSocket);
if (packet != null)
{
if (packet instanceof Packet252SharedKey && !this.isInputBeingDecrypted)
{
if (this.theNetHandler.isServerHandler())
{
this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey(this.field_74463_A);
}
this.decryptInputStream();
}
int[] aint = field_74470_c;
int i = packet.getPacketId();
aint[i] += packet.getPacketSize() + 1;
if (!this.isServerTerminating)
{
if (packet.canProcessAsync() && this.theNetHandler.canProcessPacketsAsync())
{
this.field_74490_x = 0;
packet.processPacket(this.theNetHandler);
}
else
{
this.readPackets.add(packet);
}
}
flag = true;
}
else
{
this.networkShutdown("disconnect.endOfStream", new Object[0]);
}
return flag;
}
catch (Exception exception)
{
if (!this.isTerminating)
{
this.onNetworkError(exception);
}
return false;
}
}