package common.packet;

import java.io.IOException;

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

public class CPacketCheat implements Packet<IPlayer>
{
    private ItemStack stack;
    private int slot;

    public CPacketCheat()
    {
    }

    public CPacketCheat(ItemStack stackIn, int slot, boolean full)
    {
        this.stack = stackIn.copy();
        this.slot = slot;
        this.stack.stackSize = full ? this.stack.getMaxStackSize() : 1;
    }
    
    public void processPacket(IPlayer handler)
    {
        handler.processCheat(this);
    }
    
    public void readPacketData(PacketBuffer buf) throws IOException
    {
        this.stack = buf.readItemStackFromBuffer();
        this.slot = buf.readByte();
    }
    
    public void writePacketData(PacketBuffer buf) throws IOException
    {
        buf.writeItemStackToBuffer(this.stack);
        buf.writeByte(this.slot);
    }

    public ItemStack getStack()
    {
        return this.stack;
    }

    public int getSlot()
    {
        return this.slot;
    }
}
