    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            ItemStack[] var2 = this.itemStack;
    055            int var3 = var2.length;
    056
    057            for (int var4 = 0; var4 < var3; ++var4)
    058            {
    059                ItemStack var5 = var2[var4];
    060                writeItemStack(var5, par1DataOutputStream);
    061            }
    062        }
    063
    064        /**
    065         * Passes this Packet on to the NetHandler for processing.
    066         */
    067        public void processPacket(NetHandler par1NetHandler)
    068        {
    069            par1NetHandler.handleWindowItems(this);
    070        }
    071
    072        /**
    073         * Abstract. Return the size of the packet (not counting the header).
    074         */
    075        public int getPacketSize()
    076        {
    077            return 3 + this.itemStack.length * 5;
    078        }
    079    }