001    package net.minecraft.network.packet;
002    
003    import java.io.DataInputStream;
004    import java.io.DataOutputStream;
005    import java.io.IOException;
006    
007    public class Packet100OpenWindow extends Packet
008    {
009        public int windowId;
010        public int inventoryType;
011        public String windowTitle;
012        public int slotsCount;
013    
014        public Packet100OpenWindow() {}
015    
016        public Packet100OpenWindow(int par1, int par2, String par3Str, int par4)
017        {
018            this.windowId = par1;
019            this.inventoryType = par2;
020            this.windowTitle = par3Str;
021            this.slotsCount = par4;
022        }
023    
024        /**
025         * Passes this Packet on to the NetHandler for processing.
026         */
027        public void processPacket(NetHandler par1NetHandler)
028        {
029            par1NetHandler.handleOpenWindow(this);
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() & 255;
038            this.inventoryType = par1DataInputStream.readByte() & 255;
039            this.windowTitle = readString(par1DataInputStream, 32);
040            this.slotsCount = par1DataInputStream.readByte() & 255;
041        }
042    
043        /**
044         * Abstract. Writes the raw packet data to the data stream.
045         */
046        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
047        {
048            par1DataOutputStream.writeByte(this.windowId & 255);
049            par1DataOutputStream.writeByte(this.inventoryType & 255);
050            writeString(this.windowTitle, par1DataOutputStream);
051            par1DataOutputStream.writeByte(this.slotsCount & 255);
052        }
053    
054        /**
055         * Abstract. Return the size of the packet (not counting the header).
056         */
057        public int getPacketSize()
058        {
059            return 3 + this.windowTitle.length();
060        }
061    }