15

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?

24

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"]}
  • 1
    The question has been asked 4 hours ago and you beat me by 1 minute ;) – Marco Geertsma Nov 14 '14 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. – FireStrike289 Nov 14 '14 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 Nov 14 '14 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 :/ – SMILIECHICKEN Dec 24 '15 at 17:51
  • @SMILIECHICKEN apparently you can't, or at least it's not mentioned in the wiki. – Quentin Dec 24 '15 at 18:38
1

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.13 syntax: give (your name) minecraft:TNT{CanPlaceOn:["minecraft:quartz_block"]} – pppery Aug 7 at 22:49
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]"]}

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

protected by Community Nov 26 '15 at 6:34

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.