So basically I found out minecraft is doing this to me:
[Scripting][warning]-K: unkS:-15 127 -23|minecraft:overworld
Dim: minecraft:overworld
Loc: -15 127 -23
Entity Loc: -16.067209243774414 127.99999237060547 -21.498493194580078
Entity Dimension: minecraft:overworld
Distance: 14.431276321411133
So that's the info right... tell me, does that sound like 14 blocks of distance?
So I decided to test out my script on normal js console...
class blocksMap {
static locToCoord(location) {
return Object.values(location).join(' ');
}
static coordToLoc(coord) {
let [x, y, z] = coord.split(' ').map(c => Number(c));
return {x, y, z};
}
}
function calcDistance(pA, pB) {
let d = {
x: Math.abs(pA.x - pB.x),
y: Math.abs(pA.y - pB.y),
z: Math.abs(pA.z - pB.z)
};
return d.x + d.y + d.z;
}
console.warn(calcDistance(blocksMap.coordToLoc('-15 127 -23'), blocksMap.coordToLoc('-16.067209243774414 127.99999237060547 -21.498493194580078')));
Output: 3.5687084197998047
So basically I'm confused, wtf is going on? The only thing I changed is the setup, from normal js to the entitySpawn event... and the calculations are literally so different...