Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-120803

relative coordinate selectors and testforblocks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • Minecraft 1.12.2
    • None
    • Unconfirmed

      It seems like there might be a bug when using the execute and testforblocks commands together. I'm trying to make a system that converts a player's coordinates into scoreboard values by using the testforblocks command, and so far there is only one issue.

      First off, these are the commands that I'm currently using:

      stats entity @p set AffectedBlocks @p X (used to get the number of blocks returned by testforblocks, using entity mode because of the execute command relative to the player)

      execute @p ~ ~ ~ execute @p[x=389,dx=29999611] ~ ~ ~ testforblocks 389 ~ ~ ~ ~ ~ 389 ~ ~ all (The first execute command allows for the z coordinate of the player to be tracked rather than the z value of the command block. The x=389,dx=29999611 tests for a player between x=389 and x=30000000. The testforblocks command will always return the number of blocks between the player and x=389, at the same y and z values, as long as the player is at or above an x value of 389.)

      The problem occurs with the second command. The execute @p[x=389,dx=29999611] should prevent the testforblocks command from running when the player is at x=388 or lower, but it doesn't. When moving between x=389 and x=388, the testforblocks command still runs, even though it shouldn't be able to. The command works otherwise, where going to x=387 no longer updates the command. The first two screenshots show the score changing the moment the x value changes from 389 to 388. The third one shows that the command is prevented after that point. It works properly at and above x=389, which is shown by the fourth screenshot.

      If anyone knows of a workaround it would be much appreciated. Because of the way the testforblocks command works, I need to split up the command when the player crosses a certain x value. These diagrams should display how it works, if anyone is unfamiliar with the command:

      command:execute @p ~ ~ ~ testforblocks 389 ~ ~ ~ ~ ~ 389 ~ ~ all

      1.)
      _____xbbbbp
      bbbbbx

      2.)
      pbbbbx_____
      pbbbbx_____

      p=block at player location
      b=block being tested
      x=block at x coordinate of 389
      _=empty space

      For reference, this is viewed when facing south, with left being positive x and right being negative x. In the first diagram, the blocks xbbbbp are matched with the blocks bbbbbx. This happens because the last part of the testforblocks command specifies the lower valued corner of the area checked, and the player's x value is less than 389, making it the lower valued corner. The second diagram shows that the areas being checked will always match at or above an x value of 389. As the first diagram shows, the command must be split into two parts, one that checks to the left of x=389, and one that checks to the right of x=389. And that's where the trouble starts; the testforblocks command seems to check for the player's hitbox rather than their coordinates, making the issue unavoidable until a change is made.

        1. 2017-09-22_23.29.47.png
          2017-09-22_23.29.47.png
          76 kB
        2. 2017-09-22_23.30.08.png
          2017-09-22_23.30.08.png
          73 kB
        3. 2017-09-22_23.31.22.png
          2017-09-22_23.31.22.png
          74 kB
        4. 2017-09-22_23.34.57.png
          2017-09-22_23.34.57.png
          80 kB
        5. deadzone.png
          deadzone.png
          463 kB

            Unassigned Unassigned
            RedstoneExplorer Aaron Rhodes
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: