How do you run a command after some playsound music?

How do you run a command after some playsound music? - Powerful young female athlete in activewear running along hill on background of mountainous landscape and listening to music in earphones during cardio training

I'm making a map, and, to put it simply, I need to run a command when some music finishes (played via a playsound command), and my only solution at the moment is a huge room full of repeaters making a delay as long as the music, with the command block at the end, which would work, but, for obvious reasons, I don't really want to do that. Can anyone help? If you have any more questions, ask in the comments, and I'll try and get back to you. Thanks in advance!



Best Answer

You can create an structure like that: enter image description here

And when music start to sound execute /time set command substracting 20 to 22340 by each seconds you want to delay the command.

For example:

  • If music duration is 10 seconds you must delay the command by 10 seconds so:

    22340-(10*20) = 22140

    So you must execute /time set 22140 when music starts sound

  • If music duration is 17 seconds you must delay the command by 17 seconds so:

    22340-(17*20) = 22000

    So you must execute /time set 22000 when music starts to sound

I hope I've explained that clearly




Pictures about "How do you run a command after some playsound music?"

How do you run a command after some playsound music? - Group of young multiracial women with earphones and men in sportswear running together on sunny day in park
How do you run a command after some playsound music? - Happy young woman running in field
How do you run a command after some playsound music? - From below calm young African American sportsman in earphones and sportswear looking away with interest and contemplating while running alone along street and listening to music against blurred urban environment



How do you use commands in Minecraft with sound?

After successful execution of the program, audio file will start playing. Now Click on terminal, once you see the cursor, type Ctrl+C , it will bring you out of the terminal and audio will also stop playing. That will stop the whole program, which may or may not be what the OP wants.



Playsound (1.15-1.16) (Command Tutorial) (All Command Series)




More answers regarding how do you run a command after some playsound music?

Answer 2

You could have a dispenser with arrows in it pointing towards a wooden button and when the music starts trigger the dispenser. The arrow will despawn in 60 seconds (1 minute). For example, (I did this very same contraption) I played records.11 and triggered the dispenser, shot one arrow, and afterward I had a line of repeaters (4 tick) that triggered a tp command in the end.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Andrea Piacquadio, Andrea Piacquadio, Andrea Piacquadio, Andrea Piacquadio