- Move game pause orientation protections to only the lerp factor. This is to prevent camera lerping while the game is paused. It was previously at the top of the setRotations CameraMixin function which would convert you back to vanilla rotations when paused.

- clamp local rideXrotations
- Fix player head rotations while riding.
- Lessen upwards boost on takeoff
This commit is contained in:
jackowes
2025-11-12 23:09:06 -06:00
parent d761f2b4dc
commit 1dee9bc630
4 changed files with 16 additions and 13 deletions
@@ -69,13 +69,17 @@ public class HumanoidModelMixin {
behaviour.shouldRotateRiderHead(settings, state, pokemonEntity)
);
if (entity instanceof RidePassenger playerRotater) {
//this.head.yRot = playerRotater.cobblemon$getRideYRot();
// If the player is on a rollable ride then use the ride local rotations to rotate the head
// This is to allow the player head to face the correct direction when "freelooking"
if (entity instanceof RidePassenger playerRotater &&
vehicle instanceof OrientationControllable controller &&
controller.getOrientationController().isActive()) {
this.head.xRot = playerRotater.cobblemon$getRideXRot();
headPitch = playerRotater.cobblemon$getRideXRot();
this.head.yRot = playerRotater.cobblemon$getRideYRot();
netHeadYaw = playerRotater.cobblemon$getRideYRot();
}
if (!shouldRotatePlayerHead) {
netHeadYaw = 0f;
headPitch = 0f;
@@ -308,6 +308,7 @@ public abstract class MouseHandlerMixin {
playerRotater.cobblemon$setRideXRot(playerRotater.cobblemon$getRideXRot() + f);
playerRotater.cobblemon$setRideYRot(playerRotater.cobblemon$getRideYRot() + g);
playerRotater.cobblemon$setRideXRot(Mth.clamp(playerRotater.cobblemon$getRideXRot(), -90.0F, 90.0F));
playerRotater.cobblemon$setRideYRot(Mth.clamp(playerRotater.cobblemon$getRideYRot(), -105.0F, 105.0F));
if (player.getVehicle() != null) {
player.getVehicle().onPassengerTurned(player);
}
@@ -54,7 +54,7 @@ class RidingController(
// If transitioning to air then give an upward boost
if (newTransition == RidingStyle.AIR && context?.style != RidingStyle.AIR && context?.state != null) {
val currVel = context!!.state.rideVelocity.get()
context!!.state.rideVelocity.set(Vec3(currVel.x, max(0.4, currVel.y), currVel.z))
context!!.state.rideVelocity.set(Vec3(currVel.x, max(0.1, currVel.y), currVel.z))
}
val behaviourSettings = entity.pokemon.riding.behaviours?.get(newTransition)
if (newTransition != context?.style) {
@@ -146,10 +146,6 @@ object MountedCameraRenderer {
frameTime = if (lastHandledRotationTime != Double.Companion.MIN_VALUE) d - lastHandledRotationTime else 0.0
lastHandledRotationTime = d
// Do no camera rotations if the game is paused
if(Minecraft.getInstance().isPaused) return false;
// Don't assume the camera to be attached to an entity. Ponder Scenes from create et.al. for example aren't.
if (accessor.entity == null) return false
val vehicle: Entity? = accessor.entity.vehicle
@@ -216,8 +212,11 @@ object MountedCameraRenderer {
val cutoffPitch = min(1.0, (Mth.abs(pitchDeg) / (90.0f - pitchDeadzoneDeg))) * 90.0f * sign(pitchDeg)
val lerpRateMod = Mth.cos(Math.toRadians(cutoffPitch).toFloat())
// Apply smoothing from the cameras current yaw to the yaw of the velocity vector of the ride.
val k = 10.0f // Some smoothing constant k
// Apply smoothing from the cameras current yaw to the yaw of the velocity
// vector of the ride
// Some smoothing constant k. 0.0 when game is paused to prevent lerping when game isn't running.
val k = if(Minecraft.getInstance().isPaused) 0.0f else 10.0f
val smoothingFactor: Double = lerpRateMod * frameTime * k
val newYaw = cameraAngs.y() + (Math.toRadians(degDiff.toDouble()) * smoothingFactor)
@@ -235,7 +234,6 @@ object MountedCameraRenderer {
Math.abs(lerpRateMod) * sin(rideAngs.z()) * maxRoll
).toFloat()
// Set rotations
val smoothedRot = Quaternionf().rotateYXZ(newYaw.toFloat(), newPitch.toFloat(), newRoll)
smoothRotation?.set(smoothedRot)
@@ -289,8 +287,8 @@ object MountedCameraRenderer {
}
if (returnTimer < 1f) {
//Rotation is taken from entity since we no longer handle mouse ourselves
//Stops a period of time when you can't input anything.
// Rotation is taken from entity since we no longer handle mouse ourselves
// Stops a period of time when you can't input anything.
val interpolatedRoll = Mth.lerp(returnTimer, rollAngleStart, 0.0f)
val pitch = Math.toRadians(-accessor.entity.xRot.toDouble()).toFloat()
val yaw = Math.toRadians((180 - accessor.entity.yRot).toDouble()).toFloat()