    001    package net.minecraft.network.packet;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import java.io.DataInputStream;
    006    import java.io.DataOutputStream;
    007    import java.io.IOException;
    008    import net.minecraft.item.ItemStack;
    009
    010    public class Packet5PlayerInventory extends Packet
    011    {
    012        /** Entity ID of the object. */
    013        public int entityID;
    014
    015        /** Equipment slot: 0=held, 1-4=armor slot */
    016        public int slot;
    017
    018        /** The item in the slot format (an ItemStack) */
    019        private ItemStack itemSlot;
    020
    021        public Packet5PlayerInventory() {}
    022
    023        public Packet5PlayerInventory(int par1, int par2, ItemStack par3ItemStack)
    024        {
    025            this.entityID = par1;
    026            this.slot = par2;
    027            this.itemSlot = par3ItemStack == null ? null : par3ItemStack.copy();
    028        }
    029
    030        /**
    031         * Abstract. Reads the raw packet data from the data stream.
    032         */
    033        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    034        {
    035            this.entityID = par1DataInputStream.readInt();
    036            this.slot = par1DataInputStream.readShort();
    037            this.itemSlot = readItemStack(par1DataInputStream);
    038        }
    039
    040        /**
    041         * Abstract. Writes the raw packet data to the data stream.
    042         */
    043        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    044        {
    045            par1DataOutputStream.writeInt(this.entityID);
    046            par1DataOutputStream.writeShort(this.slot);
    047            writeItemStack(this.itemSlot, par1DataOutputStream);
    048        }
    049
    050        /**
    051         * Passes this Packet on to the NetHandler for processing.
    052         */
    053        public void processPacket(NetHandler par1NetHandler)
    054        {
    055            par1NetHandler.handlePlayerInventory(this);
    056        }
    057
    058        /**
    059         * Abstract. Return the size of the packet (not counting the header).
    060         */
    061        public int getPacketSize()
    062        {
    063            return 8;
    064        }
    065
    066        @SideOnly(Side.CLIENT)
    067
    068        /**
    069         * Gets the item in the slot format (an ItemStack)
    070         */
    071        public ItemStack getItemSlot()
    072        {
    073            return this.itemSlot;
    074        }
    075
    076        /**
    077         * only false for the abstract Packet class, all real packets return true
    078         */
    079        public boolean isRealPacket()
    080        {
    081            return true;
    082        }
    083
    084        /**
    085         * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
    086         * class
    087         */
    088        public boolean containsSameEntityIDAs(Packet par1Packet)
    089        {
    090            Packet5PlayerInventory var2 = (Packet5PlayerInventory)par1Packet;
    091            return var2.entityID == this.entityID && var2.slot == this.slot;
    092        }
    093    }