    001package net.minecraft.network.packet;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.io.DataInputStream;
    006import java.io.DataOutputStream;
    007import java.io.IOException;
    008import java.util.ArrayList;
    009import java.util.Iterator;
    010import java.util.List;
    011import net.minecraft.util.Vec3;
    012import net.minecraft.world.ChunkPosition;
    013
    014public class Packet60Explosion extends Packet
    015{
    016    public double explosionX;
    017    public double explosionY;
    018    public double explosionZ;
    019    public float explosionSize;
    020    public List chunkPositionRecords;
    021    private float field_73610_f;
    022    private float field_73611_g;
    023    private float field_73617_h;
    024
    025    public Packet60Explosion() {}
    026
    027    public Packet60Explosion(double par1, double par3, double par5, float par7, List par8List, Vec3 par9Vec3)
    028    {
    029        this.explosionX = par1;
    030        this.explosionY = par3;
    031        this.explosionZ = par5;
    032        this.explosionSize = par7;
    033        this.chunkPositionRecords = new ArrayList(par8List);
    034
    035        if (par9Vec3 != null)
    036        {
    037            this.field_73610_f = (float)par9Vec3.xCoord;
    038            this.field_73611_g = (float)par9Vec3.yCoord;
    039            this.field_73617_h = (float)par9Vec3.zCoord;
    040        }
    041    }
    042
    043    /**
    044     * Abstract. Reads the raw packet data from the data stream.
    045     */
    046    public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    047    {
    048        this.explosionX = par1DataInputStream.readDouble();
    049        this.explosionY = par1DataInputStream.readDouble();
    050        this.explosionZ = par1DataInputStream.readDouble();
    051        this.explosionSize = par1DataInputStream.readFloat();
    052        int i = par1DataInputStream.readInt();
    053        this.chunkPositionRecords = new ArrayList(i);
    054        int j = (int)this.explosionX;
    055        int k = (int)this.explosionY;
    056        int l = (int)this.explosionZ;
    057
    058        for (int i1 = 0; i1 < i; ++i1)
    059        {
    060            int j1 = par1DataInputStream.readByte() + j;
    061            int k1 = par1DataInputStream.readByte() + k;
    062            int l1 = par1DataInputStream.readByte() + l;
    063            this.chunkPositionRecords.add(new ChunkPosition(j1, k1, l1));
    064        }
    065
    066        this.field_73610_f = par1DataInputStream.readFloat();
    067        this.field_73611_g = par1DataInputStream.readFloat();
    068        this.field_73617_h = par1DataInputStream.readFloat();
    069    }
    070
    071    /**
    072     * Abstract. Writes the raw packet data to the data stream.
    073     */
    074    public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    075    {
    076        par1DataOutputStream.writeDouble(this.explosionX);
    077        par1DataOutputStream.writeDouble(this.explosionY);
    078        par1DataOutputStream.writeDouble(this.explosionZ);
    079        par1DataOutputStream.writeFloat(this.explosionSize);
    080        par1DataOutputStream.writeInt(this.chunkPositionRecords.size());
    081        int i = (int)this.explosionX;
    082        int j = (int)this.explosionY;
    083        int k = (int)this.explosionZ;
    084        Iterator iterator = this.chunkPositionRecords.iterator();
    085
    086        while (iterator.hasNext())
    087        {
    088            ChunkPosition chunkposition = (ChunkPosition)iterator.next();
    089            int l = chunkposition.x - i;
    090            int i1 = chunkposition.y - j;
    091            int j1 = chunkposition.z - k;
    092            par1DataOutputStream.writeByte(l);
    093            par1DataOutputStream.writeByte(i1);
    094            par1DataOutputStream.writeByte(j1);
    095        }
    096
    097        par1DataOutputStream.writeFloat(this.field_73610_f);
    098        par1DataOutputStream.writeFloat(this.field_73611_g);
    099        par1DataOutputStream.writeFloat(this.field_73617_h);
    100    }
    101
    102    /**
    103     * Passes this Packet on to the NetHandler for processing.
    104     */
    105    public void processPacket(NetHandler par1NetHandler)
    106    {
    107        par1NetHandler.handleExplosion(this);
    108    }
    109
    110    /**
    111     * Abstract. Return the size of the packet (not counting the header).
    112     */
    113    public int getPacketSize()
    114    {
    115        return 32 + this.chunkPositionRecords.size() * 3 + 3;
    116    }
    117
    118    @SideOnly(Side.CLIENT)
    119    public float func_73607_d()
    120    {
    121        return this.field_73610_f;
    122    }
    123
    124    @SideOnly(Side.CLIENT)
    125    public float func_73609_f()
    126    {
    127        return this.field_73611_g;
    128    }
    129
    130    @SideOnly(Side.CLIENT)
    131    public float func_73608_g()
    132    {
    133        return this.field_73617_h;
    134    }
    135}