Distance between locations is incorrect

Hello, I am trying to calculate the distance between two locations. The code I use is found below.

// Variables loc1 and loc2 are initialized previously
int distance = (int) loc1.getPosition().distance(loc2.getPosition())

However, the distance returned is far from what it should be.

loc1: Located at X:-170 Y:67 Z:371
loc2: Located at X:-173 Y:67 Z:371

The variable distance should be 3, but when running the code, it is 21. Does anyone know what I am doing wrong?

I think something else must be wrong in your code.

    public static void main(String[] args) {
        Vector3d p1 = new Vector3d(-170, 67, 371);
        Vector3d p2 = new Vector3d(-173, 67, 371);
        int distance = (int) p1.distance(p2);
        System.out.println(distance);
    }

Output: 3
Perhaps loc1 or loc2 are not what you think? (Print out getPosition())