I am making an adventure map and am making it so that you craft a piece of tnt that should be placed on an observer. Though, when it is crafted it can't be placed on anything. I have tried several times with different commands but none seem to work.
/replaceitem entity @p [name=tnt]slot.weapon.mainhand 1 tnt 1 0 {"minecraft:can_place_on":{"blocks":["observer"]}}
This is one command i've tried several times. It looks promising but says that "no targets matched selector". Even if the "[name=tnt]" is swapped by "[name=!tnt]" (that should make it so that everything exept tnt changes) the tnt changes.
I would be greatful if anyone could help me.