Here you can find the source of euclideanDistance(int startX, int startY, int startZ, int endX, int endY, int endZ)
See link below for more information about how this works http://www.policyalmanac.org/games/aStarTutorial.htm Thanks to @Adamki11s, who's source I took inspiration from on how to do this, check out his Bukkit post here: https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/
public static double euclideanDistance(int startX, int startY, int startZ, int endX, int endY, int endZ)
//package com.java2s; /* // w w w. ja v a2 s .co m * Enderstone * Copyright (C) 2014 Sander Gielisse and Fernando van Loenhout * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * * See link below for more information about how this works * http://www.policyalmanac.org/games/aStarTutorial.htm * * Thanks to @Adamki11s, who's source I took inspiration from on how to do this, check out his Bukkit post here: * https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/ * */ public static double euclideanDistance(int startX, int startY, int startZ, int endX, int endY, int endZ) { double dx = startX - endX; double dy = startY - endY; double dz = startZ - endZ; return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz)); } }