How can I make a block only be placed on certain other blocks

I want people to only be able to place TNT on only Quartz Blocks and I’ve see this done before where you can only place blocks on certain other blocks but I’m not sure of the command used to do that.

Does anyone know?

Answer

From the wiki, about Item NBT tags :

Blocks can be given tags to specify what blocks they may be placed
against in Adventure mode […]

tag: The tag tag.
CanPlaceOn: Determines which blocks that blocks with this tag can be
placed against in adventure mode.

As the give command takes the Item’s tag tag as last parameter, you just have to drop your list of blocks in there :

// Give one block of stone that can be placed on grass or dirt
give @p minecraft:stone 1 0 {CanPlaceOn:["minecraft:grass","minecraft:dirt"]}

Or, in 1.13+:

give @p stone{CanPlaceOn:["minecraft:grass","minecraft:dirt"]}

Attribution
Source : Link , Question Author : FireStrike289 , Answer Author : Quentin

Leave a Comment