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

83

Improve execute if data

7 Comments

Please sign in to leave a comment.

Sorted by oldest
  • 3
    Registered User commented
    Comment actions Permalink

    I can totally agree!

  • 4
    Registered User 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
    Registered User 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.

  • 2
    Registered User 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
  • 1
    Registered User commented
    Comment actions Permalink

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

  • 1
    Registered User commented
    Comment actions Permalink

    Yes!

    200% agree!

  • 1
    Registered User commented
    Comment actions Permalink

    We need this!