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