    001package net.minecraft.network.packet;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.io.DataInputStream;
    006import java.io.DataOutputStream;
    007import java.io.IOException;
    008import java.util.List;
    009import net.minecraft.entity.DataWatcher;
    010
    011public class Packet40EntityMetadata extends Packet
    012{
    013    public int entityId;
    014    private List metadata;
    015
    016    public Packet40EntityMetadata() {}
    017
    018    public Packet40EntityMetadata(int par1, DataWatcher par2DataWatcher, boolean par3)
    019    {
    020        this.entityId = par1;
    021
    022        if (par3)
    023        {
    024            this.metadata = par2DataWatcher.func_75685_c();
    025        }
    026        else
    027        {
    028            this.metadata = par2DataWatcher.unwatchAndReturnAllWatched();
    029        }
    030    }
    031
    032    /**
    033     * Abstract. Reads the raw packet data from the data stream.
    034     */
    035    public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    036    {
    037        this.entityId = par1DataInputStream.readInt();
    038        this.metadata = DataWatcher.readWatchableObjects(par1DataInputStream);
    039    }
    040
    041    /**
    042     * Abstract. Writes the raw packet data to the data stream.
    043     */
    044    public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    045    {
    046        par1DataOutputStream.writeInt(this.entityId);
    047        DataWatcher.writeObjectsInListToStream(this.metadata, par1DataOutputStream);
    048    }
    049
    050    /**
    051     * Passes this Packet on to the NetHandler for processing.
    052     */
    053    public void processPacket(NetHandler par1NetHandler)
    054    {
    055        par1NetHandler.handleEntityMetadata(this);
    056    }
    057
    058    /**
    059     * Abstract. Return the size of the packet (not counting the header).
    060     */
    061    public int getPacketSize()
    062    {
    063        return 5;
    064    }
    065
    066    @SideOnly(Side.CLIENT)
    067    public List getMetadata()
    068    {
    069        return this.metadata;
    070    }
    071}