Solved Playing a record to a player

Discussion in 'Plugin Development' started by davidovski, Jan 2, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    davidovski

    I am working on a plugin where in some worlds a record is looped to a player. I've already sorted out the playing of the record:
    Code:
    p.playSound(p.getLocation(), Sound.RECORD_MALL, 1, 1);
    or
    Code:
    p.playEffect(p.getLocation(), Effect.RECORD_PLAY, Material.RECORD_6.getId());
    Both of these methods have the same outcome, but there is one problem. The sound is played at the location of the player at that moment, and if the player moves away, the sound gets fainter and is un hearable.
    Is there a way to make the sound follow the player instead of staying in one spot?
     
  2. You can increase the third parameter (the volume) for making the sound hearable in bigger range.

    For instance, by setting the third parameter to 10, the sound is heard in an approximate 150 blocks radius.
     
    Asparock likes this.
  3. Offline

    davidovski

    I tried that, but it only is hearable 15 blocks away. It does seem to be a bit louder were the location is. Also, I have found out that playeffect makes it work from further away, but only about 50blocks.
     
  4. Offline

    Zombie_Striker

    @davidovski
    To make the sound's radius increase, increase the volume. If you use Integer.MAXVALUE, the sound will be able to be heard from anywhere on the map.
     
  5. Offline

    davidovski

    @Zombie_Striker Thanks, I'll try that first thing tomorrow!

    Yes, it worked. The cool thing is, if you turn around you can hear where the sound is coming from, if you have headphones... sweet!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 3, 2017
  6. Offline

    Zombie_Striker

    @davidovski
    If your problem has been solved, mark this thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page