    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 var2 = par1DataInputStream.readInt();
    053        this.chunkPositionRecords = new ArrayList(var2);
    054        int var3 = (int)this.explosionX;
    055        int var4 = (int)this.explosionY;
    056        int var5 = (int)this.explosionZ;
    057
    058        for (int var6 = 0; var6 < var2; ++var6)
    059        {
    060            int var7 = par1DataInputStream.readByte() + var3;
    061            int var8 = par1DataInputStream.readByte() + var4;
    062            int var9 = par1DataInputStream.readByte() + var5;
    063            this.chunkPositionRecords.add(new ChunkPosition(var7, var8, var9));
    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 var2 = (int)this.explosionX;
    082        int var3 = (int)this.explosionY;
    083        int var4 = (int)this.explosionZ;
    084        Iterator var5 = this.chunkPositionRecords.iterator();
    085
    086        while (var5.hasNext())
    087        {
    088            ChunkPosition var6 = (ChunkPosition)var5.next();
    089            int var7 = var6.x - var2;
    090            int var8 = var6.y - var3;
    091            int var9 = var6.z - var4;
    092            par1DataOutputStream.writeByte(var7);
    093            par1DataOutputStream.writeByte(var8);
    094            par1DataOutputStream.writeByte(var9);
    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}