OpenNBS / OpenNoteBlockStudio

An open-source Minecraft music maker.
https://opennbs.org/
MIT License
728 stars 50 forks source link

Music doesn't play when the command is run via command blocks #421

Closed partyofocelots closed 7 months ago

partyofocelots commented 9 months ago

Minecraft version: Forge 1.20.1 (This bug also appears in Vanilla)

I want to start the music with command blocks but it doesn't work. if I use the same command in the player chat/console, then it works for some reason. wth?

miclol commented 9 months ago

The datapack uses tags to start and stop the music and scoreboards to control the timing of the music. Since they need to be applied to entities, running it on a command block will not work since a command block is not an entity. A workaround you could do is instead of running function yoursong:play, run execute as @p run function yoursong:play. This command just tells the command block to use the closest player as a proxy to start the music.

partyofocelots commented 9 months ago

The datapack uses tags to start and stop the music and scoreboards to control the timing of the music. Since they need to be applied to entities, running it on a command block will not work since a command block is not an entity. A workaround you could do is instead of running function yoursong:play, run execute as @p run function yoursong:play. This command just tells the command block to use the closest player as a proxy to start the music.

ok thanks