    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 Packet41EntityEffect extends Packet
    008    {
    009        public int entityId;
    010        public byte effectId;
    011
    012        /** The effect's amplifier. */
    013        public byte effectAmplifier;
    014        public short duration;
    015
    016        public Packet41EntityEffect() {}
    017
    018        public Packet41EntityEffect(int par1, PotionEffect par2PotionEffect)
    019        {
    020            this.entityId = par1;
    021            this.effectId = (byte)(par2PotionEffect.getPotionID() & 255);
    022            this.effectAmplifier = (byte)(par2PotionEffect.getAmplifier() & 255);
    023            this.duration = (short)par2PotionEffect.getDuration();
    024        }
    025
    026        /**
    027         * Abstract. Reads the raw packet data from the data stream.
    028         */
    029        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    030        {
    031            this.entityId = par1DataInputStream.readInt();
    032            this.effectId = par1DataInputStream.readByte();
    033            this.effectAmplifier = par1DataInputStream.readByte();
    034            this.duration = par1DataInputStream.readShort();
    035        }
    036
    037        /**
    038         * Abstract. Writes the raw packet data to the data stream.
    039         */
    040        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    041        {
    042            par1DataOutputStream.writeInt(this.entityId);
    043            par1DataOutputStream.writeByte(this.effectId);
    044            par1DataOutputStream.writeByte(this.effectAmplifier);
    045            par1DataOutputStream.writeShort(this.duration);
    046        }
    047
    048        /**
    049         * Passes this Packet on to the NetHandler for processing.
    050         */
    051        public void processPacket(NetHandler par1NetHandler)
    052        {
    053            par1NetHandler.handleEntityEffect(this);
    054        }
    055
    056        /**
    057         * Abstract. Return the size of the packet (not counting the header).
    058         */
    059        public int getPacketSize()
    060        {
    061            return 8;
    062        }
    063
    064        /**
    065         * only false for the abstract Packet class, all real packets return true
    066         */
    067        public boolean isRealPacket()
    068        {
    069            return true;
    070        }
    071
    072        /**
    073         * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
    074         * class
    075         */
    076        public boolean containsSameEntityIDAs(Packet par1Packet)
    077        {
    078            Packet41EntityEffect var2 = (Packet41EntityEffect)par1Packet;
    079            return var2.entityId == this.entityId && var2.effectId == this.effectId;
    080        }
    081    }