package common.packet;

import java.io.IOException;

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

public class SPacketAnimation implements Packet<IClientPlayer>
{
    private int entityId;
    private int type;
//    private int par;

    public SPacketAnimation()
    {
    }

    public SPacketAnimation(Entity ent, int animationType)
    {
        this.entityId = ent.getId();
        this.type = animationType;
//        this.par = 0;
    }

//    public S0BPacketAnimation(Entity ent, int animationType, int par)
//    {
//        this.entityId = ent.getId();
//        this.type = animationType;
//        this.par = par;
//    }
    
    public void readPacketData(PacketBuffer buf) throws IOException
    {
        this.entityId = buf.readVarIntFromBuffer();
        this.type = buf.readUnsignedByte();
//        this.par = buf.readVarIntFromBuffer();
    }
    
    public void writePacketData(PacketBuffer buf) throws IOException
    {
        buf.writeVarIntToBuffer(this.entityId);
        buf.writeByte(this.type);
//        buf.writeVarIntToBuffer(this.par);
    }
    
    public void processPacket(IClientPlayer handler)
    {
        handler.handleAnimation(this);
    }

    public int getEntityID()
    {
        return this.entityId;
    }

    public int getAnimationType()
    {
        return this.type;
    }

//    public int getParameter()
//    {
//        return this.par;
//    }
}
