    001    package net.minecraft.src;
    002
    003    import java.io.DataInputStream;
    004    import java.io.DataOutputStream;
    005    import java.io.IOException;
    006    import java.util.List;
    007
    008    public class Packet104WindowItems extends Packet
    009    {
    010        /**
    011         * The id of window which items are being sent for. 0 for player inventory.
    012         */
    013        public int windowId;
    014
    015        /** Stack of items */
    016        public ItemStack[] itemStack;
    017
    018        public Packet104WindowItems() {}
    019
    020        public Packet104WindowItems(int par1, List par2List)
    021        {
    022            this.windowId = par1;
    023            this.itemStack = new ItemStack[par2List.size()];
    024
    025            for (int var3 = 0; var3 < this.itemStack.length; ++var3)
    026            {
    027                ItemStack var4 = (ItemStack)par2List.get(var3);
    028                this.itemStack[var3] = var4 == null ? null : var4.copy();
    029            }
    030        }
    031
    032        /**
    033         * Abstract. Reads the raw packet data from the data stream.
    034         */
    035        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    036        {
    037            this.windowId = par1DataInputStream.readByte();
    038            short var2 = par1DataInputStream.readShort();
    039            this.itemStack = new ItemStack[var2];
    040
    041            for (int var3 = 0; var3 < var2; ++var3)
    042            {
    043                this.itemStack[var3] = readItemStack(par1DataInputStream);
    044            }
    045        }
    046
    047        /**
    048         * Abstract. Writes the raw packet data to the data stream.
    049         */
    050        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    051        {
    052            par1DataOutputStream.writeByte(this.windowId);
    053            par1DataOutputStream.writeShort(this.itemStack.length);
    054
    055            for (int var2 = 0; var2 < this.itemStack.length; ++var2)
    056            {
    057                writeItemStack(this.itemStack[var2], par1DataOutputStream);
    058            }
    059        }
    060
    061        /**
    062         * Passes this Packet on to the NetHandler for processing.
    063         */
    064        public void processPacket(NetHandler par1NetHandler)
    065        {
    066            par1NetHandler.handleWindowItems(this);
    067        }
    068
    069        /**
    070         * Abstract. Return the size of the packet (not counting the header).
    071         */
    072        public int getPacketSize()
    073        {
    074            return 3 + this.itemStack.length * 5;
    075        }
    076    }