diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index f4c8ae2d..a0ffdb96 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -35,6 +35,11 @@ import net.minecraft.util.text.TextFormatting; */ public interface Helper { + /** + * Instance of {@link Helper}. Used for static-context reference. + */ + Helper HELPER = new Helper() {}; + ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format( "%s[%sBaritone%s]%s", TextFormatting.DARK_PURPLE, diff --git a/src/main/java/baritone/utils/Utils.java b/src/main/java/baritone/utils/Utils.java index 49f6b49d..12be404b 100755 --- a/src/main/java/baritone/utils/Utils.java +++ b/src/main/java/baritone/utils/Utils.java @@ -27,6 +27,8 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import static baritone.utils.Helper.HELPER; + /** * @author Brady * @since 8/1/2018 12:56 AM @@ -115,12 +117,12 @@ public final class Utils { } public static double playerDistanceToCenter(BlockPos pos) { - EntityPlayerSP player = (new Helper() {}).player(); + EntityPlayerSP player = HELPER.player(); return distanceToCenter(pos, player.posX, player.posY, player.posZ); } public static double playerFlatDistanceToCenter(BlockPos pos) { - EntityPlayerSP player = (new Helper() {}).player(); + EntityPlayerSP player = HELPER.player(); return distanceToCenter(pos, player.posX, pos.getY() + 0.5, player.posZ); }