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    import net.minecraft.entity.effect.EntityLightningBolt;
008    import net.minecraft.util.MathHelper;
009    
010    public class Packet71Weather extends Packet
011    {
012        public int entityID;
013        public int posX;
014        public int posY;
015        public int posZ;
016        public int isLightningBolt;
017    
018        public Packet71Weather() {}
019    
020        public Packet71Weather(Entity par1Entity)
021        {
022            this.entityID = par1Entity.entityId;
023            this.posX = MathHelper.floor_double(par1Entity.posX * 32.0D);
024            this.posY = MathHelper.floor_double(par1Entity.posY * 32.0D);
025            this.posZ = MathHelper.floor_double(par1Entity.posZ * 32.0D);
026    
027            if (par1Entity instanceof EntityLightningBolt)
028            {
029                this.isLightningBolt = 1;
030            }
031        }
032    
033        /**
034         * Abstract. Reads the raw packet data from the data stream.
035         */
036        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
037        {
038            this.entityID = par1DataInputStream.readInt();
039            this.isLightningBolt = par1DataInputStream.readByte();
040            this.posX = par1DataInputStream.readInt();
041            this.posY = par1DataInputStream.readInt();
042            this.posZ = par1DataInputStream.readInt();
043        }
044    
045        /**
046         * Abstract. Writes the raw packet data to the data stream.
047         */
048        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
049        {
050            par1DataOutputStream.writeInt(this.entityID);
051            par1DataOutputStream.writeByte(this.isLightningBolt);
052            par1DataOutputStream.writeInt(this.posX);
053            par1DataOutputStream.writeInt(this.posY);
054            par1DataOutputStream.writeInt(this.posZ);
055        }
056    
057        /**
058         * Passes this Packet on to the NetHandler for processing.
059         */
060        public void processPacket(NetHandler par1NetHandler)
061        {
062            par1NetHandler.handleWeather(this);
063        }
064    
065        /**
066         * Abstract. Return the size of the packet (not counting the header).
067         */
068        public int getPacketSize()
069        {
070            return 17;
071        }
072    }