mojira.dev
REALMS-11810

Flipped X and Z values on Realms in Scripting API

Explination

When getting
block.loaction or
entity.location
In the context of a Realm, the resulting Vector3 has its X and Z values flipped.
Meaning; When one calls for a block's location that is at "x: 15 y: 6 z: -75", the script will return "x: -75 y: 6 z: 15" instead of "x: 15 y: 6 z: -75" 

[media]

demonstrates this bug as it is on a Realm VS a self-hosted world

 

With the demonstration, are linked photos of the pack's manifest.json and the script's index.js
Showing the bug is accuring within the 1.10.0-Stable Version of the Scriting API

"dependencies": [{ "module_name": "@minecraft/server", "version": "1.10.0" },{ "module_name": "@minecraft/server-ui", "version": "1.1.0" }]
import { world } from '@minecraft/server';
world.afterEvents.buttonPush.subscribe(({ source, block }) => {    world.sendMessage('§eButton V3Pos:§7 ' + Object.values(block.location).map(v => v.toFixed(2)).join(' '));    world.sendMessage('§6Player V3Pos:§7 ' + Object.values(source.location).map(v => v.toFixed(2)).join(' '));});

Reproduction

To reprodude this bug on your own, download the

[media]

pack which is attached below, containing the exact same code as in the screenshots.
Then activate the pack on a Minecraft Bedrock Edition Realm and simply press a button.
It should send in the game chat, the coordinates of the button pressed and the player who pressed it and with that you will be able to deduce your self that the X and Z values of the actual coordinates have been switched.
Yet repeat the same experiment on a normal world, you will obtain the expected value in your game chat, where X stays at the X position and Z at Z's.

Attachments

Comments 2

This is as-designed. Object.values doesn't have any order guarantee so it should not be relied on for specific ordering.

 

import { world } from '@minecraft/server';

world.afterEvents.buttonPush.subscribe(({ source, block }) => {
    // Order not guaranteed
    world.sendMessage('§eButton V3Pos:§7 ' + Object.values(block.location).map(v => v.toFixed(2)).join(' '));
    world.sendMessage('§6Player V3Pos:§7 ' + Object.values(source.location).map(v => v.toFixed(2)).join(' '));

    // Prints in order always
    world.sendMessage('§eButton V3Pos:§7 ' + `{x: ${block.location.x.toFixed(2)}, y: ${block.location.y.toFixed(2)}, z: ${block.location.z.toFixed(2)}}`);
    world.sendMessage('§6Player V3Pos:§7 ' + `{x: ${source.location.x.toFixed(2)}, y: ${source.location.y.toFixed(2)}, z: ${source.location.z.toFixed(2)}}`);
});

This is as-designed. Object.values doesn't have any order guarantee so it should not be relied on for specific ordering.

See example below.

DeathSinger4221

(Unassigned)

Unconfirmed

Bedrock

Realm, Script, ScriptingAPI

Retrieved