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