package common.packet;

import java.io.IOException;
import java.util.List;

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

public class SPacketEntityMetadata implements Packet<IClientPlayer>
{
    private int entityId;
    private List<DataWatcher.WatchableObject> field_149378_b;

    public SPacketEntityMetadata()
    {
    }

    public SPacketEntityMetadata(int entityIdIn, DataWatcher p_i45217_2_, boolean p_i45217_3_)
    {
        this.entityId = entityIdIn;

        if (p_i45217_3_)
        {
            this.field_149378_b = p_i45217_2_.getAllWatched();
        }
        else
        {
            this.field_149378_b = p_i45217_2_.getChanged();
        }
    }

    /**
     * Reads the raw packet data from the data stream.
     */
    public void readPacketData(PacketBuffer buf) throws IOException
    {
        this.entityId = buf.readVarInt();
        this.field_149378_b = DataWatcher.readWatchedListFromPacketBuffer(buf);
    }

    /**
     * Writes the raw packet data to the data stream.
     */
    public void writePacketData(PacketBuffer buf) throws IOException
    {
        buf.writeVarInt(this.entityId);
        DataWatcher.writeWatchedListToPacketBuffer(this.field_149378_b, buf);
    }

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

    public List<DataWatcher.WatchableObject> func_149376_c()
    {
        return this.field_149378_b;
    }

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