Some general cleanups
This commit is contained in:
		| @@ -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<Float, Float> desiredRotation = Utils.calcRotationFromCoords( | ||||
|                 Utils.calcCenterFromCoords(dest, world), | ||||
|                 playerEyePos); | ||||
|   | ||||
| @@ -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<Boolean> condition, Runnable runnable) { | ||||
|         if (condition.get()) { | ||||
|             runnable.run(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static Tuple<Float, Float> 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<Float, Float> 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; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user