net.minecraft.network.packet

## Class Packet

- java.lang.Object
- - net.minecraft.network.packet.Packet

- Direct Known Subclasses:
    Packet0KeepAlive, Packet100OpenWindow, Packet101CloseWindow, Packet102WindowClick, Packet103SetSlot, Packet104WindowItems, Packet105UpdateProgressbar, Packet106Transaction, Packet107CreativeSetSlot, Packet108EnchantItem, Packet10Flying, Packet130UpdateSign, Packet131MapData, Packet132TileEntityData, Packet14BlockDig, Packet15Place, Packet16BlockItemSwitch, Packet17Sleep, Packet18Animation, Packet19EntityAction, Packet1Login, Packet200Statistic, Packet201PlayerInfo, Packet202PlayerAbilities, Packet203AutoComplete, Packet204ClientInfo, Packet205ClientCommand, Packet20NamedEntitySpawn, Packet22Collect, Packet23VehicleSpawn, Packet24MobSpawn, Packet250CustomPayload, Packet252SharedKey, Packet253ServerAuthData, Packet254ServerPing, Packet255KickDisconnect, Packet25EntityPainting, Packet26EntityExpOrb, Packet28EntityVelocity, Packet29DestroyEntity, Packet2ClientProtocol, Packet30Entity, Packet34EntityTeleport, Packet35EntityHeadRotation, Packet38EntityStatus, Packet39AttachEntity, Packet3Chat, Packet40EntityMetadata, Packet41EntityEffect, Packet42RemoveEntityEffect, Packet43Experience, Packet4UpdateTime, Packet51MapChunk, Packet52MultiBlockChange, Packet53BlockChange, Packet54PlayNoteBlock, Packet55BlockDestroy, Packet56MapChunks, Packet5PlayerInventory, Packet60Explosion, Packet61DoorChange, Packet62LevelSound, Packet6SpawnPosition, Packet70GameEvent, Packet71Weather, Packet7UseEntity, Packet8UpdateHealth, Packet9Respawn

      public abstract class Packet
      extends Object

- - ### Field Summary

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `Packet()`

  - ### Method Summary

    Methods
    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(int par0)` 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 var1)` 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(DataInputStream par0DataInputStream, boolean par1, Socket par2Socket)` Read a packet, prefixed by its ID, from the data stream.
    `abstract void` | `readPacketData(DataInputStream var1)` 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 var1)` Abstract.
    `static void` | `writeString(String par0Str, DataOutputStream par1DataOutputStream)` Writes a String to the DataOutputStream

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### packetIdToClassMap

          public static IntHashMap packetIdToClassMap

      Maps packet id to packet class

    - #### creationTimeMillis

          public final long creationTimeMillis

      the system time in milliseconds when this packet was created.

    - #### receivedID

          public static long receivedID

    - #### receivedSize

          public static long receivedSize

    - #### sentID

          public static long sentID

      Assumed to be sequential by the profiler.

    - #### sentSize

          public static long sentSize

    - #### isChunkDataPacket

          public boolean isChunkDataPacket

      Only true for Packet51MapChunk, Packet52MultiBlockChange, Packet53BlockChange and Packet59ComplexEntity. Used to separate them into a different send queue.

  - ### Constructor Detail

    - #### Packet

          public Packet()

  - ### Method Detail

    - #### addIdClassMapping

          public static void addIdClassMapping(int par0,
                               boolean par1,
                               boolean par2,
                               Class par3Class)

      Adds a two way mapping between the packet ID and packet class.

    - #### getNewPacket

          public static Packet getNewPacket(int par0)

      Returns a new instance of the specified Packet class.

    - #### writeByteArray

          public static void writeByteArray(DataOutputStream par0DataOutputStream,
                            byte[] par1ArrayOfByte)
                                     throws IOException

      Writes a byte array to the DataOutputStream
      Throws:
        `IOException`

    - #### readBytesFromStream

          public static byte[] readBytesFromStream(DataInputStream par0DataInputStream)
                                            throws IOException

      the first short in the stream indicates the number of bytes to read
      Throws:
        `IOException`

    - #### getPacketId

          public final int getPacketId()

      Returns the ID of this packet.

    - #### readPacket

          public static Packet readPacket(DataInputStream par0DataInputStream,
                          boolean par1,
                          Socket par2Socket)
                                   throws IOException

      Read a packet, prefixed by its ID, from the data stream.
      Throws:
        `IOException`

    - #### writePacket

          public static void writePacket(Packet par0Packet,
                         DataOutputStream par1DataOutputStream)
                                  throws IOException

      Writes a packet, prefixed by its ID, to the data stream.
      Throws:
        `IOException`

    - #### writeString

          public static void writeString(String par0Str,
                         DataOutputStream par1DataOutputStream)
                                  throws IOException

      Writes a String to the DataOutputStream
      Throws:
        `IOException`

    - #### readString

          public static String readString(DataInputStream par0DataInputStream,
                          int par1)
                                   throws IOException

      Reads a string from a packet
      Throws:
        `IOException`

    - #### readPacketData

          public abstract void readPacketData(DataInputStream var1)
                                       throws IOException

      Abstract. Reads the raw packet data from the data stream.
      Throws:
        `IOException`

    - #### writePacketData

          public abstract void writePacketData(DataOutputStream var1)
                                        throws IOException

      Abstract. Writes the raw packet data to the data stream.
      Throws:
        `IOException`

    - #### processPacket

          public abstract void processPacket(NetHandler var1)

      Passes this Packet on to the NetHandler for processing.

    - #### getPacketSize

          public abstract int getPacketSize()

      Abstract. Return the size of the packet (not counting the header).

    - #### isRealPacket

          public boolean isRealPacket()

      only false for the abstract Packet class, all real packets return true

    - #### containsSameEntityIDAs

          public boolean containsSameEntityIDAs(Packet par1Packet)

      eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet class

    - #### canProcessAsync

          public boolean canProcessAsync()

      If this returns true, the packet may be processed on any thread; otherwise it is queued for the main thread to handle.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### readItemStack

          public static ItemStack readItemStack(DataInputStream par0DataInputStream)
                                         throws IOException

      Reads a ItemStack from the InputStream
      Throws:
        `IOException`

    - #### writeItemStack

          public static void writeItemStack(ItemStack par0ItemStack,
                            DataOutputStream par1DataOutputStream)
                                     throws IOException

      Writes the ItemStack's ID (short), then size (byte), then damage. (short)
      Throws:
        `IOException`

    - #### readNBTTagCompound

          public static NBTTagCompound readNBTTagCompound(DataInputStream par0DataInputStream)
                                                   throws IOException

      Reads a compressed NBTTagCompound from the InputStream
      Throws:
        `IOException`