Why do I have to put at @s in a execute command?



  • Here is my command block so far:

    execute as @a at @s if block ~ ~-1 ~ minecraft:diamond_block
    

    Then a comparator going into a command block:

    say hi
    

    In the first code, if I don't put at @s it doesn't work, why is that?

    And what does a comparator do next to a command block?



  • The @s target selector is used to target the entity that is executing the command. This is often referred to as "yourself" in the Minecraft help.

    @s must refer to a in-world target entity, and command blocks are not entities. It does nothing in a command block unless you do execute as first.

    If you only use as @a the command is actually still running at the location of the command block, so you are checking only the block below it. Using at @s it runs the command relative to your coordinates.

    Regarding the https://minecraft.fandom.com/wiki/Redstone_Comparator#Miscellaneous :

    A command block stores the "success count" of the last command executed, which represents the number of times the most recently used command of this command block succeeded. The comparator outputs the number of times it succeeded.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2