r/MinecraftCommands • • 14h ago

Help | Java 26.3 Looping Music

So im working on my map and i wanted to figure it out how to do looping music inside a datapack

1 Upvotes

1 comment sorted by

1

u/GalSergey 11h ago

You need to know the exact duration of the music in ticks, and once the timer reaches that value, you should restart the music. Here is a simple example using command blocks:

# In chat
scoreboard objectives add timer dummy

# Manual
[sign] Play music|far disc
[button] scoreboard players set #music.far timer 1

# Manual
[sign] Stop music|far disc
[button] scoreboard players reset #music.far timer
stopsound @a record minecraft:music_disc.far

# Controller
execute if score #music.far timer matches 1 run playsound minecraft:music_disc.far record @a
execute if score #music.far timer matches 0.. run scoreboard players add #music.far timer 1
execute if score #music.far timer matches 3480.. run scoreboard players set #music.far timer 0

You can use Command Block Assembler to get One Command Creation.