19

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?

4 Answers 4

27

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"]}
6
  • 2
    The question has been asked 4 hours ago and you beat me by 1 minute ;) Commented Nov 14, 2014 at 8:42
  • I know that but I need to know the command. /give [player] [item] [DataValue] [Amount] [Something] The something refers to the part I don't know which is where the syntax is and that's what I'm looking for. Commented Nov 14, 2014 at 8:55
  • @FireStrike289 Edited. The syntax is JSON. By the way, be cautious as give's data and amount parameters are the other way around :)
    – Quentin
    Commented Nov 14, 2014 at 10:42
  • I understand the part above, but can you put block variants into the {CanPlaceOn:[id: ... ]} part? And if so, how? I've already tried experimenting with the code, but I can figure it out :/ Commented Dec 24, 2015 at 17:51
  • @SMILIECHICKEN apparently you can't, or at least it's not mentioned in the wiki.
    – Quentin
    Commented Dec 24, 2015 at 18:38
2

Type this in commands:

/give (your name) minecraft:TNT 1 0 {CanPlaceOn:["minecraft:quartz_block"]}

IMPORTANT:
You can change

minecraft:TNT 1 0 {CanPlaceOn:["minecraft:quartzblock"]}

to whatever you like.

1
  • 1.13 syntax: give (your name) minecraft:TNT{CanPlaceOn:["minecraft:quartz_block"]}
    – pppery
    Commented Aug 7, 2019 at 22:49
1

1.20.5+ syntax:

/give @s stone[minecraft:can_place_on={blocks:["minecraft:acacia_leaves"]}]
0

Lever that you can place on diamond block! Can be used in Custom/Puzzle-Map!
/give [Username] lever 1 0 {CanPlaceOn:["minecraft:diamond_block"]}

That is a lever that you can place on diamond block! You can change it!:

/give [Username] [block] 1 0 {CanPlaceOn:["minecraft:**[Your block]**"]}

Or can place on more blocks!

/give [Username] [block] 1 0 {CanPlaceOn:["minecraft:[Your block],minecraft:[2nd block]"]}

2
  • 4
    While nice on it's own, this answer doesn't really add anything either of the previous two answers have omitted.
    – two bugs
    Commented Oct 20, 2015 at 16:22
  • 1.13 syntax: give [Username] [block]{CanPlaceOn:["minecraft:[Your block]",'minecraft:[2nd block]"]}
    – pppery
    Commented Aug 7, 2019 at 22:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .