Some general cleanups

This commit is contained in:
Brady 2018-08-02 00:17:48 -07:00
parent 854e67b9a8
commit f0c45260c6
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 3 additions and 19 deletions

View File

@ -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);

View File

@ -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;
}
}