    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;
    008
    009public class Packet63WorldParticles extends Packet
    010{
    011    /**
    012     * The name of the particle to create. A list can be found at https://gist.github.com/thinkofdeath/5110835
    013     */
    014    private String particleName;
    015
    016    /** X position of the particle. */
    017    private float posX;
    018
    019    /** Y position of the particle. */
    020    private float posY;
    021
    022    /** Z position of the particle. */
    023    private float posZ;
    024
    025    /**
    026     * This is added to the X position after being multiplied by random.nextGaussian()
    027     */
    028    private float offsetX;
    029
    030    /**
    031     * This is added to the Y position after being multiplied by random.nextGaussian()
    032     */
    033    private float offsetY;
    034
    035    /**
    036     * This is added to the Z position after being multiplied by random.nextGaussian()
    037     */
    038    private float offsetZ;
    039
    040    /** The speed of each particle. */
    041    private float speed;
    042
    043    /** The number of particles to create. */
    044    private int quantity;
    045
    046    /**
    047     * Abstract. Reads the raw packet data from the data stream.
    048     */
    049    public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    050    {
    051        this.particleName = readString(par1DataInputStream, 64);
    052        this.posX = par1DataInputStream.readFloat();
    053        this.posY = par1DataInputStream.readFloat();
    054        this.posZ = par1DataInputStream.readFloat();
    055        this.offsetX = par1DataInputStream.readFloat();
    056        this.offsetY = par1DataInputStream.readFloat();
    057        this.offsetZ = par1DataInputStream.readFloat();
    058        this.speed = par1DataInputStream.readFloat();
    059        this.quantity = par1DataInputStream.readInt();
    060    }
    061
    062    /**
    063     * Abstract. Writes the raw packet data to the data stream.
    064     */
    065    public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    066    {
    067        writeString(this.particleName, par1DataOutputStream);
    068        par1DataOutputStream.writeFloat(this.posX);
    069        par1DataOutputStream.writeFloat(this.posY);
    070        par1DataOutputStream.writeFloat(this.posZ);
    071        par1DataOutputStream.writeFloat(this.offsetX);
    072        par1DataOutputStream.writeFloat(this.offsetY);
    073        par1DataOutputStream.writeFloat(this.offsetZ);
    074        par1DataOutputStream.writeFloat(this.speed);
    075        par1DataOutputStream.writeInt(this.quantity);
    076    }
    077
    078    /**
    079     * Passes this Packet on to the NetHandler for processing.
    080     */
    081    public void processPacket(NetHandler par1NetHandler)
    082    {
    083        par1NetHandler.handleWorldParticles(this);
    084    }
    085
    086    /**
    087     * Abstract. Return the size of the packet (not counting the header).
    088     */
    089    public int getPacketSize()
    090    {
    091        return 64;
    092    }
    093
    094    @SideOnly(Side.CLIENT)
    095    public String getParticleName()
    096    {
    097        return this.particleName;
    098    }
    099
    100    @SideOnly(Side.CLIENT)
    101
    102    /**
    103     * Gets the X position of the particle.
    104     */
    105    public double getPositionX()
    106    {
    107        return (double)this.posX;
    108    }
    109
    110    @SideOnly(Side.CLIENT)
    111
    112    /**
    113     * Gets the Y position of the particle.
    114     */
    115    public double getPositionY()
    116    {
    117        return (double)this.posY;
    118    }
    119
    120    @SideOnly(Side.CLIENT)
    121
    122    /**
    123     * Gets the Z position of the particle.
    124     */
    125    public double getPositionZ()
    126    {
    127        return (double)this.posZ;
    128    }
    129
    130    @SideOnly(Side.CLIENT)
    131
    132    /**
    133     * This is added to the X position after being multiplied by random.nextGaussian()
    134     */
    135    public float getOffsetX()
    136    {
    137        return this.offsetX;
    138    }
    139
    140    @SideOnly(Side.CLIENT)
    141
    142    /**
    143     * This is added to the Y position after being multiplied by random.nextGaussian()
    144     */
    145    public float getOffsetY()
    146    {
    147        return this.offsetY;
    148    }
    149
    150    @SideOnly(Side.CLIENT)
    151
    152    /**
    153     * This is added to the Z position after being multiplied by random.nextGaussian()
    154     */
    155    public float getOffsetZ()
    156    {
    157        return this.offsetZ;
    158    }
    159
    160    @SideOnly(Side.CLIENT)
    161
    162    /**
    163     * Gets the speed of the particles.
    164     */
    165    public float getSpeed()
    166    {
    167        return this.speed;
    168    }
    169
    170    @SideOnly(Side.CLIENT)
    171
    172    /**
    173     * Gets the number of particles to create.
    174     */
    175    public int getQuantity()
    176    {
    177        return this.quantity;
    178    }
    179}