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(DataInput par0DataInput)
the first short in the stream indicates the number of bytes to read
|
static ItemStack |
readItemStack(DataInput par0DataInput)
Reads a ItemStack from the InputStream
|
static NBTTagCompound |
readNBTTagCompound(DataInput par0DataInput)
Reads a compressed NBTTagCompound from the InputStream
|
static Packet |
readPacket(ILogAgent par0ILogAgent,
DataInput par1DataInput,
boolean par2,
Socket par3Socket)
Read a packet, prefixed by its ID, from the data stream.
|
abstract void |
readPacketData(DataInput datainput)
Abstract.
|
static String |
readString(DataInput par0DataInput,
int par1)
Reads a string from a packet
|
String |
toString() |
static void |
writeByteArray(DataOutput par0DataOutput,
byte[] par1ArrayOfByte)
Writes a byte array to the DataOutputStream
|
static void |
writeItemStack(ItemStack par0ItemStack,
DataOutput par1DataOutput)
Writes the ItemStack's ID (short), then size (byte), then damage.
|
static void |
writePacket(Packet par0Packet,
DataOutput par1DataOutput)
Writes a packet, prefixed by its ID, to the data stream.
|
abstract void |
writePacketData(DataOutput dataoutput)
Abstract.
|
static void |
writeString(String par0Str,
DataOutput par1DataOutput)
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(DataOutput par0DataOutput, byte[] par1ArrayOfByte) throws IOException
IOException
public static byte[] readBytesFromStream(DataInput par0DataInput) throws IOException
IOException
public final int getPacketId()
public static Packet readPacket(ILogAgent par0ILogAgent, DataInput par1DataInput, boolean par2, Socket par3Socket) throws IOException
IOException
public static void writePacket(Packet par0Packet, DataOutput par1DataOutput) throws IOException
IOException
public static void writeString(String par0Str, DataOutput par1DataOutput) throws IOException
IOException
public static String readString(DataInput par0DataInput, int par1) throws IOException
IOException
public abstract void readPacketData(DataInput datainput) throws IOException
IOException
public abstract void writePacketData(DataOutput dataoutput) 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(DataInput par0DataInput) throws IOException
IOException
public static void writeItemStack(ItemStack par0ItemStack, DataOutput par1DataOutput) throws IOException
IOException
public static NBTTagCompound readNBTTagCompound(DataInput par0DataInput) throws IOException
IOException