believe it or not, this saves thousands of object allocations per second

This commit is contained in:
Leijurv 2018-11-25 22:57:08 -08:00
parent 14daf2ce85
commit 06dd07dbc6
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -81,10 +81,9 @@ public final class VecUtils {
* @see #getBlockPosCenter(BlockPos) * @see #getBlockPosCenter(BlockPos)
*/ */
public static double distanceToCenter(BlockPos pos, double x, double y, double z) { public static double distanceToCenter(BlockPos pos, double x, double y, double z) {
Vec3d center = getBlockPosCenter(pos); double xdiff = pos.getX() + 0.5 - x;
double xdiff = x - center.x; double ydiff = pos.getY() + 0.5 - y;
double ydiff = y - center.y; double zdiff = pos.getZ() + 0.5 - z;
double zdiff = z - center.z;
return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
} }