Unfortunately that doesn't work. The execute command can only use block states and damage values for detection, but no further NBT tags.
It is somewhat possible in a single player map though, but becomes tricky on multiplayer..
First: don't use names to identify blocks or entities, use tags instead. This way you can always make it easy on yourself, even if something has a name as: "The almighty dragon which is actually pretty harmless"
So: /give @p cobblestone 1 0 {Tags:["theoneblock]}. Now you have 'theoneblock', time to place it somewhere.
This will check if the player is standing on 'theoneblock'.
Here is also where the problems start. For a single player map this should be enough, you now know that the player is standing where you want them, so now you can simply apply your effects to them.
Multiplayer not so much because the only real selection you have is that 'a' player is standing on cobblestone. In those case it's best to use specific coordinates.
(edit)
Almost forgot: be sure to set up a second chain which detects that players have moved away from the cobble so that they can be untagged
Most of this information is actually inaccurate.
First of all, item tags and entity tags are different. You described entity tags, but when detecting entity tags, the NBT looks exactly the same as when summoned: {Tags:["theoneblock"]}
No, you misunderstood. You are using the entity "Tags" list on an item.. That is not correct. Plus, when you use the give command, the given NBT data is placed inside the {Item:{tag:{here}}} compound. When summoning any entity you can assign "Tags", they are located in the top of the NBT data compound, so placing them inside the Item->tag compound does nothing. Especially because it isn't an entity.
There is a thing called custom item NBT tags. They're actual NBT tags that only work for items, they are not in a list like entity "Tags", they are not strings, they are bools that you can name and define yourself. For example: {Item:{tag:{custom:1b}}}
You can summon an item as an item tile entity. "minecraft:item" is an entity. If you use this command you can summon an item with both custom item NBT tags and entity "Tags":
Now while it is an item tile entity that no one has picked up, you can target it using "@e[tag=itReallyIsDirtDoe]".
Once someone picks it up you can test that it is in their inventory with this:
testfor @a {Inventory:[{tag:{notdirt:1b}}]}
Just so you know, custom item tags are not really documented on the wiki.
If you are referring to the tag->BlockEntityTag compound, then again, you are mistaken. These are used for real tags, not custom, that should be applied when the item is placed. Like the command in a command block or inventory of a chest. You cannot put "custom:1b" tags here, nor entity "Tags", for that matter.
Interesting, I suppose this means that custom item tags can actually be of any type and not only byte. I always kinda wondered about that, but never bothered to test it as a byte is always sufficient since the value to test against must be hard coded anyway. Unless.. I wonder if you had a system of custom items and had different classes for sets, like obsidian tools for example. If you wanted to use custom tags to easily identify them in commands, you could do obsidtool:"hoe"/"shovel"/"pickaxe"/"axe" then you could test for that string when testing for the tool as well as being able to test if the tag exists and it is an obsidian tool without having to test all 4 values by simply testing for obsidtool:"". Since the tag is empty, I think it should return true even if the tag is nonexistant.
I am looking to for a way to detect a custom named block in a command so I can apply an effect to a player standing on it.
Here is an example that will put a flame effect on any player standing on cobblestone:
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:cobblestone 0 particle flame ~ ~1 ~ 1 1 1 0.15 100 force
Lets say I give myself a cobblestone name "Target":
/give @p cobblestone 1 0 {display:{Name:"Target"}}
How can I execute my command with this custom named block or a custom block? (if its a custom block I need to know to to make one)
I think only certain blocks will keep their name when placed, like chests.
Thanks
I am making a Realm server map so I wont be using this method. I am doing this instead:
execute @e[type=armor_stand,name=SpawnPoint] ~-1 ~ ~-1 effect @a[x=~,y=~,z=~,dx=2,dy=0,dz=2] minecraft:night_vision 450 2
This apply a potion effect to any player next to an armor stand named SpawnPoint
Most of this information is actually inaccurate.
First of all, item tags and entity tags are different. You described entity tags, but when detecting entity tags, the NBT looks exactly the same as when summoned: {Tags:["theoneblock"]}
To summon an item with a custom tag:
summon minecraft:item ~ ~ ~ {Item:{id:"minecraft:cobblestone",Count:1b,tag:{theoneblock:1b}}}
To give an item with a custom tag:
give @p minecraft:cobblestone 1 0 {theoneblock:1b}
However, in this scenario, item tags are useless as they are not retained once the item is used and it becomes a block.
No, you misunderstood. You are using the entity "Tags" list on an item.. That is not correct. Plus, when you use the give command, the given NBT data is placed inside the {Item:{tag:{here}}} compound. When summoning any entity you can assign "Tags", they are located in the top of the NBT data compound, so placing them inside the Item->tag compound does nothing. Especially because it isn't an entity.
There is a thing called custom item NBT tags. They're actual NBT tags that only work for items, they are not in a list like entity "Tags", they are not strings, they are bools that you can name and define yourself. For example: {Item:{tag:{custom:1b}}}
You can summon an item as an item tile entity. "minecraft:item" is an entity. If you use this command you can summon an item with both custom item NBT tags and entity "Tags":
summon minecraft:item ~ ~ ~ {Item:{id:"minecraft:dirt",Count:1,tag:{notdirt:1b}},Tags:["itReallyIsDirtDoe"]}
Now while it is an item tile entity that no one has picked up, you can target it using "@e[tag=itReallyIsDirtDoe]".
Once someone picks it up you can test that it is in their inventory with this:
testfor @a {Inventory:[{tag:{notdirt:1b}}]}
Just so you know, custom item tags are not really documented on the wiki.
If you are referring to the tag->BlockEntityTag compound, then again, you are mistaken. These are used for real tags, not custom, that should be applied when the item is placed. Like the command in a command block or inventory of a chest. You cannot put "custom:1b" tags here, nor entity "Tags", for that matter.
Interesting, I suppose this means that custom item tags can actually be of any type and not only byte. I always kinda wondered about that, but never bothered to test it as a byte is always sufficient since the value to test against must be hard coded anyway. Unless.. I wonder if you had a system of custom items and had different classes for sets, like obsidian tools for example. If you wanted to use custom tags to easily identify them in commands, you could do obsidtool:"hoe"/"shovel"/"pickaxe"/"axe" then you could test for that string when testing for the tool as well as being able to test if the tag exists and it is an obsidian tool without having to test all 4 values by simply testing for obsidtool:"". Since the tag is empty, I think it should return true even if the tag is nonexistant.