#314 Reduce camera motion and apply the client setting for fov scale to the flight camera

This commit is contained in:
Sollace 2024-03-25 19:57:21 +00:00
parent 54cbf2c238
commit 9e329ac2f9
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 22 additions and 20 deletions

View file

@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
import com.minelittlepony.unicopia.client.render.spell.DarkVortexSpellRenderer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Vec3d;
public class PlayerCamera extends MotionCompositor {
@ -18,30 +19,28 @@ public class PlayerCamera extends MotionCompositor {
}
public float calculateRoll() {
return player.getInterpolator().interpolate("roll", (float)applyModifiers(-getMotionRoll()), 15);
}
double roll = 0;
public float calculateFirstPersonRoll() {
return player.getInterpolator().interpolate("roll_fp", (float)applyModifiers(-getMotionRoll() * getFovScale() * 0.25F), 25);
}
if (player.getMotion().isFlying()) {
Vec3d vel = player.asEntity().getVelocity();
roll -= calculateRoll(player.asEntity(), vel.x, vel.y, vel.z);
}
if (player.getPhysics().isGravityNegative()) {
roll *= -1;
roll += 180;
}
if (player.asEntity().age > 10) {
roll = player.getInterpolator().interpolate("roll", (float)roll, 15);
private double getMotionRoll() {
if (!player.getMotion().isFlying() || player.asEntity().hasVehicle() || player.asEntity().isOnGround()) {
return 0;
}
Vec3d vel = player.asEntity().getVelocity();
return calculateRoll(player.asEntity(), vel.x, vel.y, vel.z);
}
private double applyModifiers(double motionRoll) {
if (player.getAcrobatics().isFloppy()) {
roll += 90;
motionRoll += 90;
}
return (float)roll;
return player.getPhysics().isGravityNegative() ? 180 - motionRoll : motionRoll;
}
public float calculatePitch(float pitch) {
@ -61,13 +60,16 @@ public class PlayerCamera extends MotionCompositor {
}
public double calculateFieldOfView(double fov) {
fov += player.getMagicalReserves().getExertion().get() / 5F;
fov += getEnergyAddition();
fov += (player.getMagicalReserves().getExertion().get() / 5F) * getFovScale();
fov += getEnergyAddition() * getFovScale();
fov += DarkVortexSpellRenderer.getCameraDistortion() * 2.5F;
return fov;
}
private float getFovScale() {
return MinecraftClient.getInstance().options.getFovEffectScale().getValue().floatValue();
}
protected float getEnergyAddition() {
int maxE = (int)Math.floor(player.getMagicalReserves().getEnergy().get() * 100);

View file

@ -36,7 +36,7 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
@Inject(method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V",
at = @At("HEAD"))
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
UnicopiaClient.getCamera().ifPresent(c -> matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(c.calculateRoll())));
UnicopiaClient.getCamera().ifPresent(c -> matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(c.calculateFirstPersonRoll())));
BatEyesApplicator.INSTANCE.enable();
}