mojira.dev
MCPE-227192

BlockRaycast faceLocation Offset on Side Faces

Summary

When using the Minecraft Bedrock Scripting API, the faceLocation property returned by player.getBlockFromViewDirection() is offset by approximately 2 pixels (≈0.125 block units) on side faces (north, south, east, west). On the up face, values range from 0 to 1 on corner pixels as expected. This offset prevents accurate quadrant mapping and pixel-perfect placement for custom block logic.

Steps to Reproduce

  1. Stand close to a block and aim at the edge or corner of a side face (north, south, east, west).

  2. Use the test script (included) to log the faceLocation values.

  3. Compare the values for the up face and side faces.

  4. Note the offset on side faces, where corner pixel values do not reach 0 or 1.

Expected Behavior

  • faceLocation should return values ranging from 0 to 1 across the entire block face, for all faces (up, down, north, south, east, west) in a linear progression

  • The hit location should accurately reflect where the player is aiming, allowing for precise mapping and placement.

Actual Behavior

  • On the up face, faceLocation values range from 0 to 1 as expected.

  • On side faces (north, south, east, west), the relevant axis (e.g., y for north/south, z for east/west) is offset upward by about 2 pixels (≈0.125 block units). Values range from ≈0.03 to ≈0.9, never reaching the true edge (0 or 1).

  • This makes it impossible to map the full face for quadrant or pixel-perfect placement reliably.

Impact

  • Prevents accurate quadrant mapping for custom block placement logic.

  • Scripts that rely on precise face hit locations (e.g., segmenting a block face into quadrants) cannot function as intended.

  • Inconsistent behaviour between the up face and side faces.

Test Case

You can use the following script to reproduce and visualise the issue. This code logs the faceLocation vector when a player uses an item on a block face. Try aiming at the edges and corners of different block faces and observe the logged values.

import { world, system } from "@minecraft/server"

world.afterEvents.itemUse.subscribe((event) => {
    const { itemStack, source: player } = event

    if (itemStack.typeId === "minecraft:arrow") {
        const hit = player.getBlockFromViewDirection()
        if (hit && hit.faceLocation) {
            player.sendMessage(`§m[Test]§r Face: ${hit.face}\nFace Location: ${JSON.stringify(hit.faceLocation)}`)
            console.log(`[Test] Face: ${hit.face}\nFace Location: ${JSON.stringify(hit.faceLocation)}`)
        }
    }
})

Sample Observations:

  • Up face:

    • NW corner pixel: { x: 0, z: 0 } (see attached image upFaceNWCorner)

    • SE corner pixel: { x: 1, z: 1 } (see attached image upFaceSECorner)

  • North face:

    • Top edge/NE corner: { x: ~1.0, y: ~0.9, z: 0 } (see attached image northFaceNECornerTop)

    • Bottom edge/NW corner: { x: ~0.0, y: ~0.03, z: 0 } (see attached image northFaceNWCornerBottom)

  • East/West faces:

    • A similar offset was observed on the relevant axes.

Additional Notes

Thank you for reviewing this report! Please let me know if you need further test cases or details.

Attachments

Comments 1

Hi!
Thank you for your report! 

However, this issue has been temporarily closed as Awaiting Response.

  • Could you upload a data pack containing mentioned script?

This ticket will automatically reopen when you reply. Thanks!

Quick Links
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki 

Evelyn Cook

(Unassigned)

Unconfirmed

Windows

Windows 11

1.21.101 Hotfix

Retrieved