    001package net.minecraft.network.packet;
    002
    003import java.io.DataInputStream;
    004import java.io.DataOutputStream;
    005import java.io.IOException;
    006import net.minecraft.scoreboard.Score;
    007
    008public class Packet207SetScore extends Packet
    009{
    010    /** An unique name to be displayed in the list. */
    011    public String itemName = "";
    012
    013    /**
    014     * The unique name for the scoreboard to be updated. Only sent when updateOrRemove does not equal 1.
    015     */
    016    public String scoreName = "";
    017
    018    /**
    019     * The score to be displayed next to the entry. Only sent when Update/Remove does not equal 1.
    020     */
    021    public int value = 0;
    022
    023    /** 0 to create/update an item. 1 to remove an item. */
    024    public int updateOrRemove = 0;
    025
    026    public Packet207SetScore() {}
    027
    028    public Packet207SetScore(Score par1, int par2)
    029    {
    030        this.itemName = par1.func_96653_e();
    031        this.scoreName = par1.func_96645_d().getName();
    032        this.value = par1.func_96652_c();
    033        this.updateOrRemove = par2;
    034    }
    035
    036    public Packet207SetScore(String par1)
    037    {
    038        this.itemName = par1;
    039        this.scoreName = "";
    040        this.value = 0;
    041        this.updateOrRemove = 1;
    042    }
    043
    044    /**
    045     * Abstract. Reads the raw packet data from the data stream.
    046     */
    047    public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    048    {
    049        this.itemName = readString(par1DataInputStream, 16);
    050        this.updateOrRemove = par1DataInputStream.readByte();
    051
    052        if (this.updateOrRemove != 1)
    053        {
    054            this.scoreName = readString(par1DataInputStream, 16);
    055            this.value = par1DataInputStream.readInt();
    056        }
    057    }
    058
    059    /**
    060     * Abstract. Writes the raw packet data to the data stream.
    061     */
    062    public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    063    {
    064        writeString(this.itemName, par1DataOutputStream);
    065        par1DataOutputStream.writeByte(this.updateOrRemove);
    066
    067        if (this.updateOrRemove != 1)
    068        {
    069            writeString(this.scoreName, par1DataOutputStream);
    070            par1DataOutputStream.writeInt(this.value);
    071        }
    072    }
    073
    074    /**
    075     * Passes this Packet on to the NetHandler for processing.
    076     */
    077    public void processPacket(NetHandler par1NetHandler)
    078    {
    079        par1NetHandler.handleSetScore(this);
    080    }
    081
    082    /**
    083     * Abstract. Return the size of the packet (not counting the header).
    084     */
    085    public int getPacketSize()
    086    {
    087        return 2 + this.itemName.length() + 2 + this.scoreName.length() + 4 + 1;
    088    }
    089}