    001    package net.minecraft.src;
    002
    003    import java.io.DataInputStream;
    004    import java.io.DataOutputStream;
    005    import java.io.IOException;
    006
    007    public class Packet28EntityVelocity extends Packet
    008    {
    009        public int entityId;
    010        public int motionX;
    011        public int motionY;
    012        public int motionZ;
    013
    014        public Packet28EntityVelocity() {}
    015
    016        public Packet28EntityVelocity(Entity par1Entity)
    017        {
    018            this(par1Entity.entityId, par1Entity.motionX, par1Entity.motionY, par1Entity.motionZ);
    019        }
    020
    021        public Packet28EntityVelocity(int par1, double par2, double par4, double par6)
    022        {
    023            this.entityId = par1;
    024            double var8 = 3.9D;
    025
    026            if (par2 < -var8)
    027            {
    028                par2 = -var8;
    029            }
    030
    031            if (par4 < -var8)
    032            {
    033                par4 = -var8;
    034            }
    035
    036            if (par6 < -var8)
    037            {
    038                par6 = -var8;
    039            }
    040
    041            if (par2 > var8)
    042            {
    043                par2 = var8;
    044            }
    045
    046            if (par4 > var8)
    047            {
    048                par4 = var8;
    049            }
    050
    051            if (par6 > var8)
    052            {
    053                par6 = var8;
    054            }
    055
    056            this.motionX = (int)(par2 * 8000.0D);
    057            this.motionY = (int)(par4 * 8000.0D);
    058            this.motionZ = (int)(par6 * 8000.0D);
    059        }
    060
    061        /**
    062         * Abstract. Reads the raw packet data from the data stream.
    063         */
    064        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    065        {
    066            this.entityId = par1DataInputStream.readInt();
    067            this.motionX = par1DataInputStream.readShort();
    068            this.motionY = par1DataInputStream.readShort();
    069            this.motionZ = par1DataInputStream.readShort();
    070        }
    071
    072        /**
    073         * Abstract. Writes the raw packet data to the data stream.
    074         */
    075        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    076        {
    077            par1DataOutputStream.writeInt(this.entityId);
    078            par1DataOutputStream.writeShort(this.motionX);
    079            par1DataOutputStream.writeShort(this.motionY);
    080            par1DataOutputStream.writeShort(this.motionZ);
    081        }
    082
    083        /**
    084         * Passes this Packet on to the NetHandler for processing.
    085         */
    086        public void processPacket(NetHandler par1NetHandler)
    087        {
    088            par1NetHandler.handleEntityVelocity(this);
    089        }
    090
    091        /**
    092         * Abstract. Return the size of the packet (not counting the header).
    093         */
    094        public int getPacketSize()
    095        {
    096            return 10;
    097        }
    098
    099        /**
    100         * only false for the abstract Packet class, all real packets return true
    101         */
    102        public boolean isRealPacket()
    103        {
    104            return true;
    105        }
    106
    107        /**
    108         * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
    109         * class
    110         */
    111        public boolean containsSameEntityIDAs(Packet par1Packet)
    112        {
    113            Packet28EntityVelocity var2 = (Packet28EntityVelocity)par1Packet;
    114            return var2.entityId == this.entityId;
    115        }
    116    }