How do you get a note block with an NBT tag so when I place it or /setblock it, it will have a specified note or instrument

I am making note block songs and I want an easy way to set the notes on note blocks. How can I set a note block’s instrument or note in my /setblock command?


The instrument and note are stored in the note block’s block states. Block states go in the []s that follow the block ID.

Here is a working command:

/setblock X Y Z minecraft:note_block[note=7]

Visit the Minecraft Wiki page on note blocks and scroll down to the Data Values section for a list of accepted values.

Because block states cannot be set in items, it means that you can only use /setblock to place the block. You can't use /give to get a note block with pre-filled notes and instruments.

Instruments can theoretically be set in block states, but Minecraft will automatically update the instrument to match the block below as soon as you try to place the block.