Switch from Float Tuple to Rotation

This commit is contained in:
Howard Stark 2018-08-05 20:54:30 -04:00
parent 3c6415d486
commit e9fedef203
No known key found for this signature in database
GPG Key ID: 9FA4E350B33067F3
3 changed files with 8 additions and 11 deletions

View File

@ -1,7 +1,7 @@
package baritone.bot.behavior.impl;
import baritone.bot.behavior.Behavior;
import net.minecraft.util.Tuple;
import baritone.bot.utils.Rotation;
import java.util.Optional;
@ -9,7 +9,7 @@ public class LookBehavior extends Behavior {
public static final LookBehavior INSTANCE = new LookBehavior();
public LookBehavior() {
private LookBehavior() {
target = Optional.empty();
}
@ -19,9 +19,9 @@ public class LookBehavior extends Behavior {
* getFirst() -> yaw
* getSecond() -> pitch
*/
private Optional<Tuple<Float, Float>> target;
private Optional<Rotation> target;
public void updateTarget(Tuple<Float, Float> target) {
public void updateTarget(Rotation target) {
this.target = Optional.of(target);
}

View File

@ -5,7 +5,6 @@ import baritone.bot.utils.Helper;
import baritone.bot.utils.Rotation;
import baritone.bot.utils.Utils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.*;
import java.util.Optional;
@ -27,7 +26,7 @@ public final class LookBehaviorUtils implements Helper{
* @param rotation {@link LookBehavior#target}
* @return vector of the rotation
*/
public static Vec3d calcVec3dFromRotation(Tuple<Float, Float> rotation) {
public static Vec3d calcVec3dFromRotation(Rotation rotation) {
float f = MathHelper.cos(-rotation.getFirst() * 0.017453292F - (float) Math.PI);
float f1 = MathHelper.sin(-rotation.getFirst() * 0.017453292F - (float) Math.PI);
float f2 = -MathHelper.cos(-rotation.getSecond() * 0.017453292F);
@ -57,7 +56,7 @@ public final class LookBehaviorUtils implements Helper{
return Optional.empty();
}
private static RayTraceResult raytraceTowards(Tuple<Float, Float> rotation) {
private static RayTraceResult raytraceTowards(Rotation rotation) {
double blockReachDistance = (double) mc.playerController.getBlockReachDistance();
Vec3d vec3 = mc.player.getPositionEyes(1.0F);
Vec3d vec31 = calcVec3dFromRotation(rotation);

View File

@ -1,8 +1,6 @@
package baritone.bot.utils;
import baritone.bot.behavior.impl.LookBehavior;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
@ -14,7 +12,7 @@ import net.minecraft.world.World;
*/
public final class Utils {
public static Tuple<Float, Float> calcRotationFromCoords(BlockPos orig, BlockPos dest) {
public static Rotation calcRotationFromCoords(BlockPos orig, BlockPos dest) {
return calcRotationFromVec3d(vec3dFromBlockPos(orig), vec3dFromBlockPos(dest));
}
@ -23,7 +21,7 @@ public final class Utils {
*
* @param orig
* @param dest
* @return Rotation Tuple {@link LookBehavior#target}
* @return Rotation {@link Rotation}
*/
public static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest) {
double yaw = Math.atan2(orig.x - dest.x, -orig.z + dest.z);