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