/**
   * Plays a sound effect with the volume and pitch of the parameters passed. The sound isn't
   * affected by position of the player (full volume and center balanced)
   */
  public void playSoundFX(String par1Str, float par2, float par3) {
    if (this.loaded && this.options.soundVolume != 0.0F) {
      SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);
      soundpoolentry =
          SoundEvent.getResult(new PlaySoundEffectEvent(this, soundpoolentry, par1Str, par2, par3));

      if (soundpoolentry != null && par2 > 0.0F) {
        this.latestSoundID = (this.latestSoundID + 1) % 256;
        String s1 = "sound_" + this.latestSoundID;
        this.sndSystem.newSource(
            false,
            s1,
            soundpoolentry.getSoundUrl(),
            soundpoolentry.getSoundName(),
            false,
            0.0F,
            0.0F,
            0.0F,
            0,
            0.0F);

        if (par2 > 1.0F) {
          par2 = 1.0F;
        }

        par2 *= 0.25F;
        this.sndSystem.setPitch(s1, par3);
        this.sndSystem.setVolume(s1, par2 * this.options.soundVolume);
        MinecraftForge.EVENT_BUS.post(new PlaySoundEffectSourceEvent(this, s1));
        this.sndSystem.play(s1);
      }
    }
  }
  /** If its time to play new music it starts it up. */
  public void playRandomMusicIfReady() {
    if (this.loaded && this.options.musicVolume != 0.0F) {
      if (!this.sndSystem.playing("BgMusic") && !this.sndSystem.playing("streaming")) {
        if (this.ticksBeforeMusic > 0) {
          --this.ticksBeforeMusic;
        } else {
          SoundPoolEntry soundpoolentry = this.soundPoolMusic.getRandomSound();
          soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(this, soundpoolentry));

          if (soundpoolentry != null) {
            this.ticksBeforeMusic = this.rand.nextInt(MUSIC_INTERVAL) + MUSIC_INTERVAL;
            this.sndSystem.backgroundMusic(
                "BgMusic", soundpoolentry.getSoundUrl(), soundpoolentry.getSoundName(), false);
            this.sndSystem.setVolume("BgMusic", this.options.musicVolume);
            this.sndSystem.play("BgMusic");
          }
        }
      }
    }
  }
  /** Plays a sound. Args: soundName, x, y, z, volume, pitch */
  public void playSound(
      String par1Str, float par2, float par3, float par4, float par5, float par6) {
    if (this.loaded && this.options.soundVolume != 0.0F) {
      SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);
      soundpoolentry =
          SoundEvent.getResult(
              new PlaySoundEvent(this, soundpoolentry, par1Str, par2, par3, par4, par5, par6));

      if (soundpoolentry != null && par5 > 0.0F) {
        this.latestSoundID = (this.latestSoundID + 1) % 256;
        String s1 = "sound_" + this.latestSoundID;
        float f5 = 16.0F;

        if (par5 > 1.0F) {
          f5 *= par5;
        }

        this.sndSystem.newSource(
            par5 > 1.0F,
            s1,
            soundpoolentry.getSoundUrl(),
            soundpoolentry.getSoundName(),
            false,
            par2,
            par3,
            par4,
            2,
            f5);

        if (par5 > 1.0F) {
          par5 = 1.0F;
        }

        this.sndSystem.setPitch(s1, par6);
        this.sndSystem.setVolume(s1, par5 * this.options.soundVolume);
        MinecraftForge.EVENT_BUS.post(new PlaySoundSourceEvent(this, s1, par2, par3, par4));
        this.sndSystem.play(s1);
      }
    }
  }
  public void playStreaming(String par1Str, float par2, float par3, float par4) {
    if (this.loaded && (this.options.soundVolume != 0.0F || par1Str == null)) {
      String s1 = "streaming";

      if (this.sndSystem.playing(s1)) {
        this.sndSystem.stop(s1);
      }

      if (par1Str != null) {
        SoundPoolEntry soundpoolentry =
            this.soundPoolStreaming.getRandomSoundFromSoundPool(par1Str);
        soundpoolentry =
            SoundEvent.getResult(
                new PlayStreamingEvent(this, soundpoolentry, par1Str, par2, par3, par4));

        if (soundpoolentry != null) {
          if (this.sndSystem.playing("BgMusic")) {
            this.sndSystem.stop("BgMusic");
          }

          this.sndSystem.newStreamingSource(
              true,
              s1,
              soundpoolentry.getSoundUrl(),
              soundpoolentry.getSoundName(),
              false,
              par2,
              par3,
              par4,
              2,
              64.0F);
          this.sndSystem.setVolume(s1, 0.5F * this.options.soundVolume);
          MinecraftForge.EVENT_BUS.post(new PlayStreamingSourceEvent(this, s1, par2, par3, par4));
          this.sndSystem.play(s1);
        }
      }
    }
  }