Are you sure you want to report this?

We've split up the commands, scripting and mods, and add ons category! Please be sure you get your thread in the right place.


Improve execute if data


Post a new comment:

Please sign in to leave a comment.

Sorted by oldest
  • 2
    Alex Testria commented
    Comment actions Permalink

    I can totally agree!

  • 3
    SkorpGaming commented
    Comment actions Permalink

    Please don't forget

    matches X

    where X is a double. This way, you don't need a scoreboard to test for fixed numbers.

  • 2
    YRUKillingMe commented
    Comment actions Permalink

    Expecially needed for storing and reading the result of a command with

    /execute store success storage ...
    /execute if data storage ...

    If you try checking with the second command, it can't differentiate whether the first command failed or not! In both cases it stores a value, but that value is not checked.

  • 0
    YRUKillingMe commented
    Comment actions Permalink

    Turns out, you actually can test whether the nbt data matches a pre-determined value. It's not as versatile as what you're suggesting, but at least we have a workaround for now.

    You just need to use the standard nbt syntax and it will check if the data matches:

    /execute if data entity @s {SelectedItem:{Count:1b}}

    Which would almost work like your example:

    /execute if data entity @s SelectedItem.Count matches score @s testscore
  • 0
    Comment actions Permalink

    matches tag doesn't really make sense, how would the game know what kind of tag to use?