diff --git a/src/main/java/baritone/bot/pathing/actions/Action.java b/src/main/java/baritone/bot/pathing/actions/Action.java index f7f8b5a6..2c810ddf 100644 --- a/src/main/java/baritone/bot/pathing/actions/Action.java +++ b/src/main/java/baritone/bot/pathing/actions/Action.java @@ -2,12 +2,7 @@ package baritone.bot.pathing.actions; import baritone.bot.behavior.Behavior; import baritone.bot.utils.Utils; -import net.minecraft.block.state.BlockStateBase; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.BlockWorldState; -import net.minecraft.block.state.IBlockState; import net.minecraft.util.Tuple; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; public abstract class Action extends Behavior { @@ -15,7 +10,7 @@ public abstract class Action extends Behavior { protected ActionState currentState; Action(BlockPos dest) { - BlockPos playerEyePos = new BlockPos(player.posX, player.posY+1.62, player.posZ); + BlockPos playerEyePos = new BlockPos(player.posX, player.posY + player.getEyeHeight(), player.posZ); Tuple desiredRotation = Utils.calcRotationFromCoords( Utils.calcCenterFromCoords(dest, world), playerEyePos); diff --git a/src/main/java/baritone/bot/utils/Utils.java b/src/main/java/baritone/bot/utils/Utils.java index 9228880e..e53f7908 100755 --- a/src/main/java/baritone/bot/utils/Utils.java +++ b/src/main/java/baritone/bot/utils/Utils.java @@ -1,33 +1,23 @@ package baritone.bot.utils; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.util.Tuple; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.function.Supplier; - /** * @author Brady * @since 8/1/2018 12:56 AM */ public final class Utils { - public static void ifConditionThen(Supplier condition, Runnable runnable) { - if (condition.get()) { - runnable.run(); - } - } - public static Tuple calcRotationFromCoords(BlockPos orig, BlockPos dest) { double yaw = Math.atan2(orig.getX() - dest.getX(), -orig.getZ() + dest.getZ()); double dist = Math.sqrt((orig.getX() - dest.getX()) * (orig.getX() - dest.getX()) + (-orig.getZ() + dest.getZ()) * (-orig.getZ() + dest.getZ())); double pitch = Math.atan2(orig.getY() - dest.getY(), dist); - Tuple rotation = new Tuple<>((float) (yaw * 180 / Math.PI), + return new Tuple<>((float) (yaw * 180 / Math.PI), (float) (pitch * 180 / Math.PI)); - return rotation; } public static BlockPos calcCenterFromCoords(BlockPos orig, World world) { @@ -36,9 +26,8 @@ public final class Utils { double xDiff = (bbox.minX + bbox.maxX) / 2; double yDiff = (bbox.minY + bbox.maxY) / 2; double zDiff = (bbox.minZ + bbox.maxZ) / 2; - BlockPos centerPos = new BlockPos(orig.getX() + xDiff, + return new BlockPos(orig.getX() + xDiff, orig.getY() + yDiff, orig.getZ() + zDiff); - return centerPos; } }