I've done this before, but I have forgotten how to do it. I tried every command but nothing is working, and I was trying to be quick. Is there a way to do this in Minecraft 1.16?
31 Answer
You can use the 'CanPlaceOn' NBT/component with the give command to give you levers which are only allowed to be placed on emerald blocks when the player is in Adventure mode.
Java:
/give @s minecraft:lever{CanPlaceOn:["minecraft:emerald_block"]} 64Bedrock:
/give @s lever 64 0 {"can_place_on":{"blocks":["emerald_block"]}}You can't restrict them if they are in either Survival or Creative mode.