Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-185119

Scripting getBlockFromViewDirection is inaccurate

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.21.30.22 Preview, 1.21.30.21 Preview, 1.21.2 Hotfix, 1.21.51 Hotfix
    • Community Consensus
    • Multiple

      The bug

      The point returned by player.getBlockFromViewDirection does not match the actual block or face the player is looking at in some cases.

      How to reproduce

      1. Download and open the attached world. It has a script that displays red particles as a preview for block placement.
      2. /tp @s -7.43 7.01 -40.60 61.48 28.40

      Expected behavior
      The red particles should be on top of the block, since that's where you're looking.

      Observed behavior
      They're on the side instead.

      Notes

      The relevant JS code is in scripts/entry.js. I've also attached it here for convenience.

        1. Test World Beta.mcworld
          1.57 MB
        2. screenshot-1.png
          screenshot-1.png
          360 kB
        3. entry.js
          1 kB

            tryashtar [Mod] tryashtar
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: