package common.packet;

import java.io.IOException;

import common.network.IPlayer;
import common.network.Packet;
import common.network.PacketBuffer;

public class CPacketAction implements Packet<IPlayer>
{
    private Action action;
    private int auxData;

    public CPacketAction()
    {
    }

    public CPacketAction(Action action)
    {
        this(action, 0);
    }

    public CPacketAction(Action action, int auxData)
    {
        this.action = action;
        this.auxData = auxData;
    }
    
    public void readPacketData(PacketBuffer buf) throws IOException
    {
        this.action = buf.readEnumValue(Action.class);
        this.auxData = buf.readVarInt();
    }
    
    public void writePacketData(PacketBuffer buf) throws IOException
    {
        buf.writeEnumValue(this.action);
        buf.writeVarInt(this.auxData);
    }
    
    public void processPacket(IPlayer handler)
    {
        handler.processAction(this);
    }

    public Action getAction()
    {
        return this.action;
    }

    public int getAuxData()
    {
        return this.auxData;
    }

    public static enum Action
    {
    	OPEN_EDITOR,
    	CLOSE_EDITOR,
    	CANCEL_EDITOR,
    	SELECT_CHARACTER,
    	DELETE_CHARACTER,
    	SWING_ARM,
    	SET_ITEMSLOT,
        START_SNEAKING,
        STOP_SNEAKING,
//        STOP_SLEEPING,
        START_SPRINTING,
        STOP_SPRINTING,
        START_HOVER,
        STOP_HOVER,
        RIDING_JUMP,
        OPEN_INVENTORY,
        START_FLYING,
        STOP_FLYING,
        PERFORM_RESPAWN,
//        REQUEST_STATS,
//        SET_MODELPARTS,
        SET_HEIGHT,
        SET_SPECIES,
        SET_CLASS,
        SELECT_TRADE,
//        SET_BEACON,
        INTERACT,
        ATTACK,
        CLOSE_CONTAINER,
        CONFIRM_TRANSACTION,
        ENCHANT_ITEM,
        SET_ALIGN,
        ITEM_ACTION,
        GOD,
        NOCLIP,
        SPEED,
        HEAL,
        REPAIR,
        PERF,
        MAGNET,
//        SET_VIEWDIST,
        WARP_MODE,
        START_PROFILING,
        STOP_PROFILING;
//        SHUTDOWN;
    }
}
