4

Is there any way to avoid specifying the data value when using the detect syntax of execute (execute ... detect ~ ~ ~ ...)?

I want to execute on an item and detect if there is stone under it and an anvil at ~+1 ~ ~, but the problem is that an anvil facing towards +x has a different data value than one facing towards -x etc. Do you know any way in Minecraft Vanilla to ignore this data value or put there universal one? (I can't just stop command because i need <command> that is after <data value>)

At the moment command looks like that:

execute @e[type=Item] ~ ~ ~ detect ~ ~-1 ~ minecraft:stone 0 execute @e[type=Item] ~ ~ ~ detect ~1 ~ ~ minecraft:anvil <data value> say hi
1
  • As of 1.13, there is no such thing as a "data value", making this question obsolete.
    – pppery
    Jun 26, 2019 at 17:02

1 Answer 1

4

-1 fits all possible data values

From the wiki entry on execute (emphasis mine):

block and data (detect mode only)

Specifies the block id and data which the block at (x2,y2,z2) must match for the command to run. block must be a valid block id (for example, minecraft:stone), and data must be a valid block data for that type of block or -1 to match any block data.

This use of -1 is not limited to execute. Other commands, such as testforblock also work like this.

3
  • I'm so stupid. All commands, data tags and things like these are frome gamepedia, but oh my god i didn't notice that. Thank you so much!
    – HardnerPL
    Nov 23, 2015 at 13:59
  • However sory i can't give you +1 cause of my low reputation :(
    – HardnerPL
    Nov 23, 2015 at 13:59
  • @HardnerPL Don't worry about it. Also, you do now.
    – MrLemon
    Nov 23, 2015 at 15:30

You must log in to answer this question.

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