I'm making "magic blocks": if you are standing on a specific block you get a potion effect like speed, instant health, strength, etc. The only problem is while trying to make it survival friendly I want the player to have to rename a diamond block to the certain name to make the potion effects work. /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:diamond_block 0 /effect @a minecraft:strength 5 30

So that's what I use currently but is there an NBT tag that makes it so the detect part can testfor a diamond block that's been named in an anvil?

  • 1
    Once placed, the block loses its custom name Commented Jun 2, 2015 at 9:50
  • If you are okay with it, maybe use two command blocks with a hopper clock, then I can certainly help. That won't hurt, since you are making an adventure map. So mention me here, and I'll reply ASAP
    – Rajat Jain
    Commented Jun 2, 2015 at 15:23
  • Rajat Jain 4 I'm actually not making it in an adventure map just a concept but it could definitely be used in adventure maps. But what do you mean by 2 command blocks running off a hopper clock?
    – Veritas025
    Commented Jun 2, 2015 at 20:01

2 Answers 2


When you place a named block, it loses its name tag, making it impossible to detect if it was ever named. What you can do, however, is set a custom data value:

/setblock ~ ~ ~ diamond_block 1

Then, replace detect ~ ~-1 ~ diamond_block 0 with diamond_block 1. You can use values 1 through 15, but values above 15 are not supported.

Note: In some versions of the game (and possibly the latest updates), blocks with custom data may have a missing texture, and the custom data may not be saved properly. You'll have to look into this yourself as I can't test it at the moment.

  • I am aware that this is an option, but as I said I'm trying to make it survival friendly so is it possible to give a data value to a block in survival?
    – Veritas025
    Commented Jun 1, 2015 at 22:30
  • Nevermind I have an Idea, I can have fill clock doing /execute @e[type=Item,name=CUSTOM_NAME] /setblock ~ ~ ~ diamond_block 1 So that way I can have a custom named block and press q and throw it on the ground as an item and then it will do the /setblock with custom data value
    – Veritas025
    Commented Jun 1, 2015 at 22:43
  • As far as I know, custom metadata was broken with the introduction of block states. Commented Jun 4, 2015 at 2:02

Blocks cannot have names. If you use an anvil, that only renames the item stack. Instead of trying to detect the block, try spawning an invisible marker armor stand with a custom name. e.g. /summon ArmorStand ~ ~-1 ~ {Invisible:1, Marker: 1, CustomName: "Magic Block"}. You could then use the execute command to do things based on that armor stand.

  • Since it is supposed to be survival friendly, you would still need to detect the use of a renamed item to summon the armor stand in the first place.
    – MrLemon
    Commented Jun 4, 2015 at 8:38

You must log in to answer this question.

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