Reputation: 51
I am having a bit of trouble with sounds in my bukkit plugin (Or Spigot 1.9) and the problem I have is I want to use this command:
player.playSound(loc, Sound.RECORD_BLOCKS, 1f, 1f);
Which works fine it's just. I want the sound to continue playing as the player runs around. So I find that when the command is executed, the sound plays and then as you move, the sound disappears and it can't be heard unless you go back to the place in which the command was executed.
Upvotes: 1
Views: 4961
Reputation: 6483
The player.playSound(Location location, Sound sound, float volume, float pitch)
method internally sends a packet to the client by specifying an effect and a given location. Therefore there is not way of changing the location without sending a new packet and duplicating the sound that the player is already hearing.
Nevertheless, the third parameter of the aforementioned method corresponds to the volume of the sound that is played. By increasing it, you can widen the radius within which the player can hear the sound. For instance, after a quick test, by setting it to 10, you can hear the music in an approximate 150 blocks radius.
Hope this helps!
Upvotes: 3