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