001package net.minecraft.network.packet; 002 003import java.io.DataInputStream; 004import java.io.DataOutputStream; 005import java.io.IOException; 006 007public class Packet100OpenWindow extends Packet 008{ 009 public int windowId; 010 public int inventoryType; 011 public String windowTitle; 012 public int slotsCount; 013 014 /** 015 * If false, the client will look up a string like "window.minecart". If true, the client uses what the server 016 * provides. 017 */ 018 public boolean useProvidedWindowTitle; 019 020 public Packet100OpenWindow() {} 021 022 public Packet100OpenWindow(int par1, int par2, String par3Str, int par4, boolean par5) 023 { 024 this.windowId = par1; 025 this.inventoryType = par2; 026 this.windowTitle = par3Str; 027 this.slotsCount = par4; 028 this.useProvidedWindowTitle = par5; 029 } 030 031 /** 032 * Passes this Packet on to the NetHandler for processing. 033 */ 034 public void processPacket(NetHandler par1NetHandler) 035 { 036 par1NetHandler.handleOpenWindow(this); 037 } 038 039 /** 040 * Abstract. Reads the raw packet data from the data stream. 041 */ 042 public void readPacketData(DataInputStream par1DataInputStream) throws IOException 043 { 044 this.windowId = par1DataInputStream.readByte() & 255; 045 this.inventoryType = par1DataInputStream.readByte() & 255; 046 this.windowTitle = readString(par1DataInputStream, 32); 047 this.slotsCount = par1DataInputStream.readByte() & 255; 048 this.useProvidedWindowTitle = par1DataInputStream.readBoolean(); 049 } 050 051 /** 052 * Abstract. Writes the raw packet data to the data stream. 053 */ 054 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 055 { 056 par1DataOutputStream.writeByte(this.windowId & 255); 057 par1DataOutputStream.writeByte(this.inventoryType & 255); 058 writeString(this.windowTitle, par1DataOutputStream); 059 par1DataOutputStream.writeByte(this.slotsCount & 255); 060 par1DataOutputStream.writeBoolean(this.useProvidedWindowTitle); 061 } 062 063 /** 064 * Abstract. Return the size of the packet (not counting the header). 065 */ 066 public int getPacketSize() 067 { 068 return 4 + this.windowTitle.length(); 069 } 070}