Move fromAngleAndDirection to GoalXZ
This commit is contained in:
parent
4d32ba131a
commit
2b6d86dcdd
@ -108,20 +108,13 @@ public class PathingBehavior extends Behavior {
|
||||
return;
|
||||
}
|
||||
if (msg.toLowerCase().startsWith("thisway")) {
|
||||
goal = fromAngleAndDirection(Double.parseDouble(msg.substring(7).trim()));
|
||||
goal = GoalXZ.fromDirection(playerFeetAsVec(), player().rotationYaw, Double.parseDouble(msg.substring(7).trim()));
|
||||
displayChatMessageRaw("Goal: " + goal);
|
||||
event.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public GoalXZ fromAngleAndDirection(double distance) {
|
||||
double theta = ((double) player().rotationYaw) * Math.PI / 180D;
|
||||
double x = player().posX - Math.sin(theta) * distance;
|
||||
double z = player().posZ + Math.cos(theta) * distance;
|
||||
return new GoalXZ((int) x, (int) z);
|
||||
}
|
||||
|
||||
/**
|
||||
* In a new thread, pathfind to target blockpos
|
||||
*
|
||||
|
@ -17,7 +17,9 @@
|
||||
|
||||
package baritone.bot.pathing.goals;
|
||||
|
||||
import baritone.bot.utils.Utils;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
/**
|
||||
* Useful for long-range goals that don't have a specific Y level.
|
||||
@ -54,6 +56,11 @@ public class GoalXZ implements Goal {
|
||||
return calculate(xDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Goal{x=" + x + ",z=" + z + "}";
|
||||
}
|
||||
|
||||
public static double calculate(double xDiff, double zDiff) {
|
||||
return calculate(xDiff, zDiff, 0);
|
||||
}
|
||||
@ -93,8 +100,10 @@ public class GoalXZ implements Goal {
|
||||
return (diagonal + straight) * WALK_ONE_BLOCK_COST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Goal{x=" + x + ",z=" + z + "}";
|
||||
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
||||
double theta = Utils.degToRad(yaw);
|
||||
double x = origin.x - Math.sin(theta) * distance;
|
||||
double z = origin.z + Math.cos(theta) * distance;
|
||||
return new GoalXZ((int) x, (int) z);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ public interface Helper {
|
||||
return new BlockPos(player().posX, player().posY, player().posZ);
|
||||
}
|
||||
|
||||
default Vec3d playerFeetAsVec() {
|
||||
return new Vec3d(player().posX, player().posY, player().posZ);
|
||||
}
|
||||
|
||||
default Vec3d playerHead() {
|
||||
return new Vec3d(player().posX, player().posY + player().getEyeHeight(), player().posZ);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user