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

16

Command Conditional Statements

6 Comments

Please sign in to leave a comment.

Sorted by oldest
  • 1
    Registered User commented
    Comment actions Permalink

    Imagine they add this but only for Java. I can see them doing that.

  • 1
    Registered User commented
    Comment actions Permalink

    ChikoritaLover I'm pretty sure this exists in java, with /execute. /execute in java has more arguments.

  • 1
    Registered User commented
    Comment actions Permalink

    @EXDrill2522, there is a if condition in the execute command, but it doesn't seem to have else if and else callbacks.

    Also, the execute command doesn't have while and for loops.

  • 0
    Registered User commented
    Comment actions Permalink

    I just learned of another one called foreach. It is a shortener for for loops.

    for(Object o : list) {/**Do stuff**/}

  • 0
    Registered User commented
    Comment actions Permalink

    These are actually all possible in the Java Edition of Minecraft, there are loads of ways to create conditionals if you're willing to use scoreboards.

    For the first one, we can set up a scoreboard and run the following commands in order:

    execute store result score FakePlayer myObjective if entity @s[tag=pizza] run summon minecraft:cat
    execute if score FakePlayer myObjective matches 0 store result score FakePlayer myObjective if entity @s[tag=burger] run summon minecraft:wolf
    execute if score FakePlayer myObjective matches 0 run summon parrot

    For the second one, we set a redstone block next to a repeating command chain with the message, followed by a chain command block that removes the redstone block if the required entity is not detected:

    execute if entity @a[tag=some] run say This is annoying!
    execute unless entity @a[tag=some] run setblock 12 23 34 minecraft:air

    And for the third one, we can increment a scoreboard value by 1 every time a command is run, and stop the entire command chain when the score is 10.

    In Bedrock Edition, I would advocate for getting the /stats command added to Bedrock Edition instead, to let the storage of command results to scores.

  • 0
    Registered User commented
    Comment actions Permalink

    This would open up much more possibilities and make it easier. I really don't want to mess with tons of command blocks.