package common.packet;

import java.io.IOException;

import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;

public class SPacketSetExperience implements Packet<IClientPlayer>
{
    private float progress;
    private int totalExperience;
    private int level;

    public SPacketSetExperience()
    {
    }

    public SPacketSetExperience(float progressIn, int totalExperienceIn, int levelIn)
    {
        this.progress = progressIn;
        this.totalExperience = totalExperienceIn;
        this.level = levelIn;
    }

    /**
     * Reads the raw packet data from the data stream.
     */
    public void readPacketData(PacketBuffer buf) throws IOException
    {
        this.progress = buf.readFloat();
        this.level = buf.readVarInt();
        this.totalExperience = buf.readVarInt();
    }

    /**
     * Writes the raw packet data to the data stream.
     */
    public void writePacketData(PacketBuffer buf) throws IOException
    {
        buf.writeFloat(this.progress);
        buf.writeVarInt(this.level);
        buf.writeVarInt(this.totalExperience);
    }

    /**
     * Passes this Packet on to the NetHandler for processing.
     */
    public void processPacket(IClientPlayer handler)
    {
        handler.handleSetExperience(this);
    }

    public float getProgress()
    {
        return this.progress;
    }

    public int getTotalExperience()
    {
        return this.totalExperience;
    }

    public int getLevel()
    {
        return this.level;
    }
}
