    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 Packet34EntityTeleport extends Packet
    008    {
    009        /** ID of the entity. */
    010        public int entityId;
    011
    012        /** X position of the entity. */
    013        public int xPosition;
    014
    015        /** Y position of the entity. */
    016        public int yPosition;
    017
    018        /** Z position of the entity. */
    019        public int zPosition;
    020
    021        /** Yaw of the entity. */
    022        public byte yaw;
    023
    024        /** Pitch of the entity. */
    025        public byte pitch;
    026
    027        public Packet34EntityTeleport() {}
    028
    029        public Packet34EntityTeleport(Entity par1Entity)
    030        {
    031            this.entityId = par1Entity.entityId;
    032            this.xPosition = MathHelper.floor_double(par1Entity.posX * 32.0D);
    033            this.yPosition = MathHelper.floor_double(par1Entity.posY * 32.0D);
    034            this.zPosition = MathHelper.floor_double(par1Entity.posZ * 32.0D);
    035            this.yaw = (byte)((int)(par1Entity.rotationYaw * 256.0F / 360.0F));
    036            this.pitch = (byte)((int)(par1Entity.rotationPitch * 256.0F / 360.0F));
    037        }
    038
    039        public Packet34EntityTeleport(int par1, int par2, int par3, int par4, byte par5, byte par6)
    040        {
    041            this.entityId = par1;
    042            this.xPosition = par2;
    043            this.yPosition = par3;
    044            this.zPosition = par4;
    045            this.yaw = par5;
    046            this.pitch = par6;
    047        }
    048
    049        /**
    050         * Abstract. Reads the raw packet data from the data stream.
    051         */
    052        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    053        {
    054            this.entityId = par1DataInputStream.readInt();
    055            this.xPosition = par1DataInputStream.readInt();
    056            this.yPosition = par1DataInputStream.readInt();
    057            this.zPosition = par1DataInputStream.readInt();
    058            this.yaw = (byte)par1DataInputStream.read();
    059            this.pitch = (byte)par1DataInputStream.read();
    060        }
    061
    062        /**
    063         * Abstract. Writes the raw packet data to the data stream.
    064         */
    065        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    066        {
    067            par1DataOutputStream.writeInt(this.entityId);
    068            par1DataOutputStream.writeInt(this.xPosition);
    069            par1DataOutputStream.writeInt(this.yPosition);
    070            par1DataOutputStream.writeInt(this.zPosition);
    071            par1DataOutputStream.write(this.yaw);
    072            par1DataOutputStream.write(this.pitch);
    073        }
    074
    075        /**
    076         * Passes this Packet on to the NetHandler for processing.
    077         */
    078        public void processPacket(NetHandler par1NetHandler)
    079        {
    080            par1NetHandler.handleEntityTeleport(this);
    081        }
    082
    083        /**
    084         * Abstract. Return the size of the packet (not counting the header).
    085         */
    086        public int getPacketSize()
    087        {
    088            return 34;
    089        }
    090
    091        /**
    092         * only false for the abstract Packet class, all real packets return true
    093         */
    094        public boolean isRealPacket()
    095        {
    096            return true;
    097        }
    098
    099        /**
    100         * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
    101         * class
    102         */
    103        public boolean containsSameEntityIDAs(Packet par1Packet)
    104        {
    105            Packet34EntityTeleport var2 = (Packet34EntityTeleport)par1Packet;
    106            return var2.entityId == this.entityId;
    107        }
    108    }