001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    import java.io.DataInputStream;
006    import java.io.DataOutputStream;
007    import java.io.IOException;
008    
009    public class Packet62LevelSound extends Packet
010    {
011        /** e.g. step.grass */
012        private String soundName;
013        private int field_73577_b;
014        private int field_73578_c = Integer.MAX_VALUE;
015        private int field_73575_d;
016    
017        /** 1 is 100%. Can be more. */
018        private float volume;
019    
020        /** 63 is 100%. Can be more. */
021        private int pitch;
022    
023        public Packet62LevelSound() {}
024    
025        public Packet62LevelSound(String par1Str, double par2, double par4, double par6, float par8, float par9)
026        {
027            this.soundName = par1Str;
028            this.field_73577_b = (int)(par2 * 8.0D);
029            this.field_73578_c = (int)(par4 * 8.0D);
030            this.field_73575_d = (int)(par6 * 8.0D);
031            this.volume = par8;
032            this.pitch = (int)(par9 * 63.0F);
033    
034            if (this.pitch < 0)
035            {
036                this.pitch = 0;
037            }
038    
039            if (this.pitch > 255)
040            {
041                this.pitch = 255;
042            }
043        }
044    
045        /**
046         * Abstract. Reads the raw packet data from the data stream.
047         */
048        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
049        {
050            this.soundName = readString(par1DataInputStream, 32);
051            this.field_73577_b = par1DataInputStream.readInt();
052            this.field_73578_c = par1DataInputStream.readInt();
053            this.field_73575_d = par1DataInputStream.readInt();
054            this.volume = par1DataInputStream.readFloat();
055            this.pitch = par1DataInputStream.readUnsignedByte();
056        }
057    
058        /**
059         * Abstract. Writes the raw packet data to the data stream.
060         */
061        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
062        {
063            writeString(this.soundName, par1DataOutputStream);
064            par1DataOutputStream.writeInt(this.field_73577_b);
065            par1DataOutputStream.writeInt(this.field_73578_c);
066            par1DataOutputStream.writeInt(this.field_73575_d);
067            par1DataOutputStream.writeFloat(this.volume);
068            par1DataOutputStream.writeByte(this.pitch);
069        }
070    
071        /**
072         * Passes this Packet on to the NetHandler for processing.
073         */
074        public void processPacket(NetHandler par1NetHandler)
075        {
076            par1NetHandler.handleLevelSound(this);
077        }
078    
079        /**
080         * Abstract. Return the size of the packet (not counting the header).
081         */
082        public int getPacketSize()
083        {
084            return 24;
085        }
086    
087        @SideOnly(Side.CLIENT)
088        public String func_73570_d()
089        {
090            return this.soundName;
091        }
092    
093        @SideOnly(Side.CLIENT)
094        public double func_73572_f()
095        {
096            return (double)((float)this.field_73577_b / 8.0F);
097        }
098    
099        @SideOnly(Side.CLIENT)
100        public double func_73568_g()
101        {
102            return (double)((float)this.field_73578_c / 8.0F);
103        }
104    
105        @SideOnly(Side.CLIENT)
106        public double func_73569_h()
107        {
108            return (double)((float)this.field_73575_d / 8.0F);
109        }
110    
111        @SideOnly(Side.CLIENT)
112        public float func_73571_i()
113        {
114            return this.volume;
115        }
116    
117        @SideOnly(Side.CLIENT)
118        public float func_73573_j()
119        {
120            return (float)this.pitch / 63.0F;
121        }
122    }