    001    package net.minecraft.network.packet;
    002
    003    import java.io.DataInputStream;
    004    import java.io.DataOutputStream;
    005    import java.io.IOException;
    006    import net.minecraft.entity.Entity;
    007
    008    public class Packet39AttachEntity extends Packet
    009    {
    010        public int entityId;
    011        public int vehicleEntityId;
    012
    013        public Packet39AttachEntity() {}
    014
    015        public Packet39AttachEntity(Entity par1Entity, Entity par2Entity)
    016        {
    017            this.entityId = par1Entity.entityId;
    018            this.vehicleEntityId = par2Entity != null ? par2Entity.entityId : -1;
    019        }
    020
    021        /**
    022         * Abstract. Return the size of the packet (not counting the header).
    023         */
    024        public int getPacketSize()
    025        {
    026            return 8;
    027        }
    028
    029        /**
    030         * Abstract. Reads the raw packet data from the data stream.
    031         */
    032        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    033        {
    034            this.entityId = par1DataInputStream.readInt();
    035            this.vehicleEntityId = par1DataInputStream.readInt();
    036        }
    037
    038        /**
    039         * Abstract. Writes the raw packet data to the data stream.
    040         */
    041        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    042        {
    043            par1DataOutputStream.writeInt(this.entityId);
    044            par1DataOutputStream.writeInt(this.vehicleEntityId);
    045        }
    046
    047        /**
    048         * Passes this Packet on to the NetHandler for processing.
    049         */
    050        public void processPacket(NetHandler par1NetHandler)
    051        {
    052            par1NetHandler.handleAttachEntity(this);
    053        }
    054
    055        /**
    056         * only false for the abstract Packet class, all real packets return true
    057         */
    058        public boolean isRealPacket()
    059        {
    060            return true;
    061        }
    062
    063        /**
    064         * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
    065         * class
    066         */
    067        public boolean containsSameEntityIDAs(Packet par1Packet)
    068        {
    069            Packet39AttachEntity var2 = (Packet39AttachEntity)par1Packet;
    070            return var2.entityId == this.entityId;
    071        }
    072    }