001 package net.minecraft.network.packet; 002 003 import cpw.mods.fml.relauncher.Side; 004 import cpw.mods.fml.relauncher.SideOnly; 005 import java.io.DataInputStream; 006 import java.io.DataOutputStream; 007 import java.io.IOException; 008 009 public class Packet204ClientInfo extends Packet 010 { 011 private String language; 012 private int renderDistance; 013 private int chatVisisble; 014 private boolean chatColours; 015 private int gameDifficulty; 016 private boolean showCape; 017 018 public Packet204ClientInfo() {} 019 020 @SideOnly(Side.CLIENT) 021 public Packet204ClientInfo(String par1Str, int par2, int par3, boolean par4, int par5, boolean par6) 022 { 023 this.language = par1Str; 024 this.renderDistance = par2; 025 this.chatVisisble = par3; 026 this.chatColours = par4; 027 this.gameDifficulty = par5; 028 this.showCape = par6; 029 } 030 031 /** 032 * Abstract. Reads the raw packet data from the data stream. 033 */ 034 public void readPacketData(DataInputStream par1DataInputStream) throws IOException 035 { 036 this.language = readString(par1DataInputStream, 7); 037 this.renderDistance = par1DataInputStream.readByte(); 038 byte var2 = par1DataInputStream.readByte(); 039 this.chatVisisble = var2 & 7; 040 this.chatColours = (var2 & 8) == 8; 041 this.gameDifficulty = par1DataInputStream.readByte(); 042 this.showCape = par1DataInputStream.readBoolean(); 043 } 044 045 /** 046 * Abstract. Writes the raw packet data to the data stream. 047 */ 048 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 049 { 050 writeString(this.language, par1DataOutputStream); 051 par1DataOutputStream.writeByte(this.renderDistance); 052 par1DataOutputStream.writeByte(this.chatVisisble | (this.chatColours ? 1 : 0) << 3); 053 par1DataOutputStream.writeByte(this.gameDifficulty); 054 par1DataOutputStream.writeBoolean(this.showCape); 055 } 056 057 /** 058 * Passes this Packet on to the NetHandler for processing. 059 */ 060 public void processPacket(NetHandler par1NetHandler) 061 { 062 par1NetHandler.handleClientInfo(this); 063 } 064 065 /** 066 * Abstract. Return the size of the packet (not counting the header). 067 */ 068 public int getPacketSize() 069 { 070 return 7; 071 } 072 073 public String getLanguage() 074 { 075 return this.language; 076 } 077 078 public int getRenderDistance() 079 { 080 return this.renderDistance; 081 } 082 083 public int getChatVisibility() 084 { 085 return this.chatVisisble; 086 } 087 088 public boolean getChatColours() 089 { 090 return this.chatColours; 091 } 092 093 public int getDifficulty() 094 { 095 return this.gameDifficulty; 096 } 097 098 public boolean getShowCape() 099 { 100 return this.showCape; 101 } 102 103 /** 104 * only false for the abstract Packet class, all real packets return true 105 */ 106 public boolean isRealPacket() 107 { 108 return true; 109 } 110 111 /** 112 * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet 113 * class 114 */ 115 public boolean containsSameEntityIDAs(Packet par1Packet) 116 { 117 return true; 118 } 119 }