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        private ItemStack field_73399_c;
017    
018        public Packet5PlayerInventory() {}
019    
020        public Packet5PlayerInventory(int par1, int par2, ItemStack par3ItemStack)
021        {
022            this.entityID = par1;
023            this.slot = par2;
024            this.field_73399_c = par3ItemStack == null ? null : par3ItemStack.copy();
025        }
026    
027        /**
028         * Abstract. Reads the raw packet data from the data stream.
029         */
030        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
031        {
032            this.entityID = par1DataInputStream.readInt();
033            this.slot = par1DataInputStream.readShort();
034            this.field_73399_c = readItemStack(par1DataInputStream);
035        }
036    
037        /**
038         * Abstract. Writes the raw packet data to the data stream.
039         */
040        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
041        {
042            par1DataOutputStream.writeInt(this.entityID);
043            par1DataOutputStream.writeShort(this.slot);
044            writeItemStack(this.field_73399_c, par1DataOutputStream);
045        }
046    
047        /**
048         * Passes this Packet on to the NetHandler for processing.
049         */
050        public void processPacket(NetHandler par1NetHandler)
051        {
052            par1NetHandler.handlePlayerInventory(this);
053        }
054    
055        /**
056         * Abstract. Return the size of the packet (not counting the header).
057         */
058        public int getPacketSize()
059        {
060            return 8;
061        }
062    
063        @SideOnly(Side.CLIENT)
064        public ItemStack func_73397_d()
065        {
066            return this.field_73399_c;
067        }
068    
069        /**
070         * only false for the abstract Packet class, all real packets return true
071         */
072        public boolean isRealPacket()
073        {
074            return true;
075        }
076    
077        /**
078         * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
079         * class
080         */
081        public boolean containsSameEntityIDAs(Packet par1Packet)
082        {
083            Packet5PlayerInventory var2 = (Packet5PlayerInventory)par1Packet;
084            return var2.entityID == this.entityID && var2.slot == this.slot;
085        }
086    }