Better Rotation
This commit is contained in:
@@ -69,9 +69,9 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe
|
||||
switch (event.getState()) {
|
||||
case PRE: {
|
||||
if (this.force) {
|
||||
player().rotationYaw = this.target.getFirst();
|
||||
player().rotationYaw = this.target.getYaw();
|
||||
float oldPitch = player().rotationPitch;
|
||||
float desiredPitch = this.target.getSecond();
|
||||
float desiredPitch = this.target.getPitch();
|
||||
player().rotationPitch = desiredPitch;
|
||||
if (desiredPitch == oldPitch) {
|
||||
nudgeToLevel();
|
||||
@@ -79,7 +79,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe
|
||||
this.target = null;
|
||||
} else if (silent) {
|
||||
this.lastYaw = player().rotationYaw;
|
||||
player().rotationYaw = this.target.getFirst();
|
||||
player().rotationYaw = this.target.getYaw();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe
|
||||
switch (event.getState()) {
|
||||
case PRE:
|
||||
this.lastYaw = player().rotationYaw;
|
||||
player().rotationYaw = this.target.getFirst();
|
||||
player().rotationYaw = this.target.getYaw();
|
||||
break;
|
||||
case POST:
|
||||
player().rotationYaw = this.lastYaw;
|
||||
|
||||
@@ -51,10 +51,10 @@ public final class LookBehaviorUtils implements Helper {
|
||||
* @return vector of the rotation
|
||||
*/
|
||||
public static Vec3d calcVec3dFromRotation(Rotation rotation) {
|
||||
float f = MathHelper.cos(-rotation.getFirst() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f1 = MathHelper.sin(-rotation.getFirst() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f2 = -MathHelper.cos(-rotation.getSecond() * (float) DEG_TO_RAD);
|
||||
float f3 = MathHelper.sin(-rotation.getSecond() * (float) DEG_TO_RAD);
|
||||
float f = MathHelper.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f1 = MathHelper.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f2 = -MathHelper.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
|
||||
float f3 = MathHelper.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
|
||||
return new Vec3d((double) (f1 * f2), (double) f3, (double) (f * f2));
|
||||
}
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
state.setTarget(new MovementTarget(
|
||||
new Rotation(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
||||
Utils.getBlockPosCenter(pos),
|
||||
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getFirst(), mc.player.rotationPitch),
|
||||
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getYaw(), mc.player.rotationPitch),
|
||||
false
|
||||
)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||
}
|
||||
|
||||
@@ -165,8 +165,8 @@ public class MovementTraverse extends Movement {
|
||||
|
||||
// combine the yaw to the center of the destination, and the pitch to the specific block we're trying to break
|
||||
// it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw
|
||||
float yawToDest = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())).getFirst();
|
||||
float pitchToBreak = state.getTarget().getRotation().get().getSecond();
|
||||
float yawToDest = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())).getYaw();
|
||||
float pitchToBreak = state.getTarget().getRotation().get().getPitch();
|
||||
|
||||
state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true));
|
||||
return state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||
|
||||
@@ -99,10 +99,7 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static Rotation wrapAnglesToRelative(Rotation current, Rotation target) {
|
||||
return new Rotation(
|
||||
MathHelper.wrapDegrees(target.getFirst() - current.getFirst()) + current.getFirst(),
|
||||
MathHelper.wrapDegrees(target.getSecond() - current.getSecond()) + current.getSecond()
|
||||
);
|
||||
return target.subtract(current).normalize().add(current);
|
||||
}
|
||||
|
||||
public static Vec3d vec3dFromBlockPos(BlockPos orig) {
|
||||
|
||||
Reference in New Issue
Block a user