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 Packet201PlayerInfo extends Packet 008 { 009 /** The player's name. */ 010 public String playerName; 011 012 /** Byte that tells whether the player is connected. */ 013 public boolean isConnected; 014 public int ping; 015 016 public Packet201PlayerInfo() {} 017 018 public Packet201PlayerInfo(String par1Str, boolean par2, int par3) 019 { 020 this.playerName = par1Str; 021 this.isConnected = par2; 022 this.ping = par3; 023 } 024 025 /** 026 * Abstract. Reads the raw packet data from the data stream. 027 */ 028 public void readPacketData(DataInputStream par1DataInputStream) throws IOException 029 { 030 this.playerName = readString(par1DataInputStream, 16); 031 this.isConnected = par1DataInputStream.readByte() != 0; 032 this.ping = par1DataInputStream.readShort(); 033 } 034 035 /** 036 * Abstract. Writes the raw packet data to the data stream. 037 */ 038 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 039 { 040 writeString(this.playerName, par1DataOutputStream); 041 par1DataOutputStream.writeByte(this.isConnected ? 1 : 0); 042 par1DataOutputStream.writeShort(this.ping); 043 } 044 045 /** 046 * Passes this Packet on to the NetHandler for processing. 047 */ 048 public void processPacket(NetHandler par1NetHandler) 049 { 050 par1NetHandler.handlePlayerInfo(this); 051 } 052 053 /** 054 * Abstract. Return the size of the packet (not counting the header). 055 */ 056 public int getPacketSize() 057 { 058 return this.playerName.length() + 2 + 1 + 2; 059 } 060 }