Are you looking for how to get a block with preset data into your inventory? See this post.
I have made a system where, when a button is pressed, a chest appears next to the player with some items. The problem is, /setblock
only can set an empty chest next to the player, not one with items inside. In Java Edition, this command would have worked:
setblock ~ ~ ~ chest{Items:[{Slot:0b,id:"minecraft:dirt"}]}
How can I set a chest with items next to the player?
This can also apply to signs with text, command blocks with settings, and other container blocks with items such as dispensers, droppers, hoppers, etc.