001package net.minecraft.network.packet; 002 003import java.io.DataInputStream; 004import java.io.DataOutputStream; 005import java.io.IOException; 006import net.minecraft.scoreboard.ScoreObjective; 007 008public class Packet208SetDisplayObjective extends Packet 009{ 010 /** The position of the scoreboard. 0 = list, 1 = sidebar, 2 = belowName. */ 011 public int scoreboardPosition; 012 013 /** The unique name for the scoreboard to be displayed. */ 014 public String scoreName; 015 016 public Packet208SetDisplayObjective() {} 017 018 public Packet208SetDisplayObjective(int par1, ScoreObjective par2ScoreObjective) 019 { 020 this.scoreboardPosition = par1; 021 022 if (par2ScoreObjective == null) 023 { 024 this.scoreName = ""; 025 } 026 else 027 { 028 this.scoreName = par2ScoreObjective.getName(); 029 } 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.scoreboardPosition = par1DataInputStream.readByte(); 038 this.scoreName = readString(par1DataInputStream, 16); 039 } 040 041 /** 042 * Abstract. Writes the raw packet data to the data stream. 043 */ 044 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 045 { 046 par1DataOutputStream.writeByte(this.scoreboardPosition); 047 writeString(this.scoreName, par1DataOutputStream); 048 } 049 050 /** 051 * Passes this Packet on to the NetHandler for processing. 052 */ 053 public void processPacket(NetHandler par1NetHandler) 054 { 055 par1NetHandler.handleSetDisplayObjective(this); 056 } 057 058 /** 059 * Abstract. Return the size of the packet (not counting the header). 060 */ 061 public int getPacketSize() 062 { 063 return 3 + this.scoreName.length(); 064 } 065}