Class Packet

java.lang.Object
net.minecraft.src.Packet
Direct Known Subclasses:
DebugInfoPacket, GameruleSyncPacket, HardcoreSpawnPacket, Packet0KeepAlive, Packet100OpenWindow, Packet101CloseWindow, Packet102WindowClick, Packet103SetSlot, Packet104WindowItems, Packet105UpdateProgressbar, Packet106Transaction, Packet107CreativeSetSlot, Packet108EnchantItem, Packet10Flying, Packet130UpdateSign, Packet131MapData, Packet132TileEntityData, Packet133TileEditorOpen, Packet14BlockDig, Packet15Place, Packet16BlockItemSwitch, Packet17Sleep, Packet18Animation, Packet19EntityAction, Packet1Login, Packet200Statistic, Packet201PlayerInfo, Packet202PlayerAbilities, Packet203AutoComplete, Packet204ClientInfo, Packet205ClientCommand, Packet206SetObjective, Packet207SetScore, Packet208SetDisplayObjective, Packet209SetPlayerTeam, Packet20NamedEntitySpawn, Packet22Collect, Packet23VehicleSpawn, Packet24MobSpawn, Packet250CustomPayload, Packet252SharedKey, Packet253ServerAuthData, Packet254ServerPing, Packet255KickDisconnect, Packet25EntityPainting, Packet26EntityExpOrb, Packet27PlayerInput, Packet28EntityVelocity, Packet29DestroyEntity, Packet2ClientProtocol, Packet30Entity, Packet34EntityTeleport, Packet35EntityHeadRotation, Packet38EntityStatus, Packet39AttachEntity, Packet3Chat, Packet40EntityMetadata, Packet41EntityEffect, Packet42RemoveEntityEffect, Packet43Experience, Packet44UpdateAttributes, Packet4UpdateTime, Packet51MapChunk, Packet52MultiBlockChange, Packet53BlockChange, Packet54PlayNoteBlock, Packet55BlockDestroy, Packet56MapChunks, Packet5PlayerInventory, Packet60Explosion, Packet61DoorChange, Packet62LevelSound, Packet63WorldParticles, Packet6SpawnPosition, Packet70GameEvent, Packet71Weather, Packet7UseEntity, Packet8UpdateHealth, Packet9Respawn, PlayerSyncPacket, StartBlockHarvestPacket, TimerSpeedPacket

public abstract class Packet extends Object
  • Field Details

    • packetIdToClassMap

      public static IntHashMap packetIdToClassMap
      Maps packet id to packet class
    • field_98193_m

      protected ILogAgent field_98193_m
    • 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 Details

    • Packet

      public Packet()
  • Method Details

    • 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(ILogAgent par0ILogAgent, int par1)
      Returns a new instance of the specified Packet class.
    • writeByteArray

      public static void writeByteArray(DataOutput par0DataOutput, byte[] par1ArrayOfByte) throws IOException
      Writes a byte array to the DataOutputStream
      Throws:
      IOException
    • readBytesFromStream

      public static byte[] readBytesFromStream(DataInput par0DataInput) 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(ILogAgent par0ILogAgent, DataInput par1DataInput, boolean par2, Socket par3Socket) throws IOException
      Read a packet, prefixed by its ID, from the data stream.
      Throws:
      IOException
    • writePacket

      public static void writePacket(Packet par0Packet, DataOutput par1DataOutput) throws IOException
      Writes a packet, prefixed by its ID, to the data stream.
      Throws:
      IOException
    • writeString

      public static void writeString(String par0Str, DataOutput par1DataOutput) throws IOException
      Writes a String to the DataOutputStream
      Throws:
      IOException
    • readString

      public static String readString(DataInput par0DataInput, int par1) throws IOException
      Reads a string from a packet
      Throws:
      IOException
    • readPacketData

      public abstract void readPacketData(DataInput var1) throws IOException
      Abstract. Reads the raw packet data from the data stream.
      Throws:
      IOException
    • writePacketData

      public abstract void writePacketData(DataOutput 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(DataInput par0DataInput) throws IOException
      Reads a ItemStack from the InputStream
      Throws:
      IOException
    • writeItemStack

      public static void writeItemStack(ItemStack par0ItemStack, DataOutput par1DataOutput) throws IOException
      Writes the ItemStack's ID (short), then size (byte), then damage. (short)
      Throws:
      IOException
    • readNBTTagCompound

      public static NBTTagCompound readNBTTagCompound(DataInput par0DataInput) throws IOException
      Reads a compressed NBTTagCompound from the InputStream
      Throws:
      IOException
    • writeNBTTagCompound

      protected static void writeNBTTagCompound(NBTTagCompound par0NBTTagCompound, DataOutput par1DataOutput) throws IOException
      Writes a compressed NBTTagCompound to the OutputStream
      Throws:
      IOException