From 0e6d61e90774129646d4168de69b0c2ed41f0e12 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 2 Sep 2018 14:21:34 -0500 Subject: [PATCH] Consolidate rayTraceTowards into RayTraceUtils, fixes #121 --- .../behavior/impl/LookBehaviorUtils.java | 19 ++----------------- .../java/baritone/utils/RayTraceUtils.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java b/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java index fd75c478..91b046e0 100644 --- a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java @@ -17,10 +17,7 @@ package baritone.behavior.impl; -import baritone.utils.BlockStateInterface; -import baritone.utils.Helper; -import baritone.utils.Rotation; -import baritone.utils.Utils; +import baritone.utils.*; import net.minecraft.block.BlockFire; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.*; @@ -87,18 +84,6 @@ public final class LookBehaviorUtils implements Helper { return Optional.empty(); } - private static RayTraceResult rayTraceTowards(Rotation rotation) { - double blockReachDistance = mc.playerController.getBlockReachDistance(); - Vec3d start = mc.player.getPositionEyes(1.0F); - Vec3d direction = calcVec3dFromRotation(rotation); - Vec3d end = start.add( - direction.x * blockReachDistance, - direction.y * blockReachDistance, - direction.z * blockReachDistance - ); - return mc.world.rayTraceBlocks(start, end, false, false, true); - } - /** * Checks if coordinate is reachable with the given block-face rotation offset * @@ -108,7 +93,7 @@ public final class LookBehaviorUtils implements Helper { */ protected static Optional reachableOffset(BlockPos pos, Vec3d offsetPos) { Rotation rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), offsetPos); - RayTraceResult result = rayTraceTowards(rotation); + RayTraceResult result = RayTraceUtils.rayTraceTowards(rotation); System.out.println(result); if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { if (result.getBlockPos().equals(pos)) { diff --git a/src/main/java/baritone/utils/RayTraceUtils.java b/src/main/java/baritone/utils/RayTraceUtils.java index f6547454..123e283d 100644 --- a/src/main/java/baritone/utils/RayTraceUtils.java +++ b/src/main/java/baritone/utils/RayTraceUtils.java @@ -18,6 +18,9 @@ package baritone.utils; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; + +import static baritone.behavior.impl.LookBehaviorUtils.calcVec3dFromRotation; /** * @author Brady @@ -44,4 +47,16 @@ public final class RayTraceUtils implements Helper { return result; } + + public static RayTraceResult rayTraceTowards(Rotation rotation) { + double blockReachDistance = mc.playerController.getBlockReachDistance(); + Vec3d start = mc.player.getPositionEyes(1.0F); + Vec3d direction = calcVec3dFromRotation(rotation); + Vec3d end = start.add( + direction.x * blockReachDistance, + direction.y * blockReachDistance, + direction.z * blockReachDistance + ); + return mc.world.rayTraceBlocks(start, end, false, false, true); + } }