From 06dd07dbc67b01cc6fa51c01ba7568af76aeb631 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 25 Nov 2018 22:57:08 -0800 Subject: [PATCH] believe it or not, this saves thousands of object allocations per second --- src/api/java/baritone/api/utils/VecUtils.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/utils/VecUtils.java b/src/api/java/baritone/api/utils/VecUtils.java index 090cb9d7..1df01163 100644 --- a/src/api/java/baritone/api/utils/VecUtils.java +++ b/src/api/java/baritone/api/utils/VecUtils.java @@ -81,10 +81,9 @@ public final class VecUtils { * @see #getBlockPosCenter(BlockPos) */ public static double distanceToCenter(BlockPos pos, double x, double y, double z) { - Vec3d center = getBlockPosCenter(pos); - double xdiff = x - center.x; - double ydiff = y - center.y; - double zdiff = z - center.z; + double xdiff = pos.getX() + 0.5 - x; + double ydiff = pos.getY() + 0.5 - y; + double zdiff = pos.getZ() + 0.5 - z; return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); }