public abstract class Packet extends Object
Modifier and Type | Field and Description |
---|---|
long |
creationTimeMillis
the system time in milliseconds when this packet was created.
|
boolean |
isChunkDataPacket
Only true for Packet51MapChunk, Packet52MultiBlockChange, Packet53BlockChange and Packet59ComplexEntity.
|
static IntHashMap |
packetIdToClassMap
Maps packet id to packet class
|
static long |
receivedID |
static long |
receivedSize |
static long |
sentID
Assumed to be sequential by the profiler.
|
static long |
sentSize |
Constructor and Description |
---|
Packet() |
Modifier and Type | Method and Description |
---|---|
static void |
addIdClassMapping(int par0,
boolean par1,
boolean par2,
Class par3Class)
Adds a two way mapping between the packet ID and packet class.
|
boolean |
canProcessAsync()
If this returns true, the packet may be processed on any thread; otherwise it is queued for the main thread to
handle.
|
boolean |
containsSameEntityIDAs(Packet par1Packet)
eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
class
|
static Packet |
getNewPacket(ILogAgent par0ILogAgent,
int par1)
Returns a new instance of the specified Packet class.
|
int |
getPacketId()
Returns the ID of this packet.
|
abstract int |
getPacketSize()
Abstract.
|
boolean |
isRealPacket()
only false for the abstract Packet class, all real packets return true
|
abstract void |
processPacket(NetHandler nethandler)
Passes this Packet on to the NetHandler for processing.
|
static byte[] |
readBytesFromStream(DataInputStream par0DataInputStream)
the first short in the stream indicates the number of bytes to read
|
static ItemStack |
readItemStack(DataInputStream par0DataInputStream)
Reads a ItemStack from the InputStream
|
static NBTTagCompound |
readNBTTagCompound(DataInputStream par0DataInputStream)
Reads a compressed NBTTagCompound from the InputStream
|
static Packet |
readPacket(ILogAgent par0ILogAgent,
DataInputStream par1DataInputStream,
boolean par2,
Socket par3Socket)
Read a packet, prefixed by its ID, from the data stream.
|
abstract void |
readPacketData(DataInputStream datainputstream)
Abstract.
|
static String |
readString(DataInputStream par0DataInputStream,
int par1)
Reads a string from a packet
|
String |
toString() |
static void |
writeByteArray(DataOutputStream par0DataOutputStream,
byte[] par1ArrayOfByte)
Writes a byte array to the DataOutputStream
|
static void |
writeItemStack(ItemStack par0ItemStack,
DataOutputStream par1DataOutputStream)
Writes the ItemStack's ID (short), then size (byte), then damage.
|
static void |
writePacket(Packet par0Packet,
DataOutputStream par1DataOutputStream)
Writes a packet, prefixed by its ID, to the data stream.
|
abstract void |
writePacketData(DataOutputStream dataoutputstream)
Abstract.
|
static void |
writeString(String par0Str,
DataOutputStream par1DataOutputStream)
Writes a String to the DataOutputStream
|
public static IntHashMap packetIdToClassMap
public final long creationTimeMillis
public static long receivedID
public static long receivedSize
public static long sentID
public static long sentSize
public boolean isChunkDataPacket
public static void addIdClassMapping(int par0, boolean par1, boolean par2, Class par3Class)
public static Packet getNewPacket(ILogAgent par0ILogAgent, int par1)
public static void writeByteArray(DataOutputStream par0DataOutputStream, byte[] par1ArrayOfByte) throws IOException
IOException
public static byte[] readBytesFromStream(DataInputStream par0DataInputStream) throws IOException
IOException
public final int getPacketId()
public static Packet readPacket(ILogAgent par0ILogAgent, DataInputStream par1DataInputStream, boolean par2, Socket par3Socket) throws IOException
IOException
public static void writePacket(Packet par0Packet, DataOutputStream par1DataOutputStream) throws IOException
IOException
public static void writeString(String par0Str, DataOutputStream par1DataOutputStream) throws IOException
IOException
public static String readString(DataInputStream par0DataInputStream, int par1) throws IOException
IOException
public abstract void readPacketData(DataInputStream datainputstream) throws IOException
IOException
public abstract void writePacketData(DataOutputStream dataoutputstream) throws IOException
IOException
public abstract void processPacket(NetHandler nethandler)
public abstract int getPacketSize()
public boolean isRealPacket()
public boolean containsSameEntityIDAs(Packet par1Packet)
public boolean canProcessAsync()
public static ItemStack readItemStack(DataInputStream par0DataInputStream) throws IOException
IOException
public static void writeItemStack(ItemStack par0ItemStack, DataOutputStream par1DataOutputStream) throws IOException
IOException
public static NBTTagCompound readNBTTagCompound(DataInputStream par0DataInputStream) throws IOException
IOException