Minecraft Java Edition, Minecraft Commands – How to Make Jukebox Music Follow a Player

minecraft-commandsminecraft-java-edition

Believe it or not, there are still players that listen to music discs in Minecraft, including me.

I tried making a command loop that would play different discs for me every 5 minutes. Here's what command I use:

/execute at Quijibo run playsound minecraft:music_disc.stal record Quijibo

This successfully executes the command, and the music starts playing, but if I move away from the point where I was standing, the music fades away, as if there was a jukebox playing the music that I'm moving away from.

What I want to do is have the music follow me when moving. Is this possible to do through commands?

Best Answer

In theory the minimumVolume parameter should fulfil exactly this purpose, but I couldn't get it to work. Maybe that's a bug.

But the volume parameter of /playsound can in a way actually be used to specify a spatial volume instead of an audio volume! The trick, as described in the wiki (archive):

For values greater than 1.0, the sound will not actually grow louder, but its audible range (a 16-block radius at 1.0) will be multiplied by volume. There will always be a gradual falloff to silence based on distance from the center of the sphere.

That means that you can just enter the maximum value of a Float, except that it's for some reason slightly different in Minecraft. By just trying out values I found that the maximum value is:

340282356779733661637539395458142568447.99999…

So you can use this command to play a sound everywhere:

/playsound <sound> <channel> <selector> <x> <y> <z> 340282356779733661637539395458142568447.9999999999

That way it only gets 0.000000000000000000000000000024936% quieter when you go to the other end of the world.

This even works across dimensions for some reason. But when you go through a portal, the sound stops.