mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-07 22:16:44 +01:00
#314 Reduce camera motion and apply the client setting for fov scale to the flight camera
This commit is contained in:
parent
54cbf2c238
commit
9e329ac2f9
2 changed files with 22 additions and 20 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
private double getMotionRoll() {
|
||||
if (!player.getMotion().isFlying() || player.asEntity().hasVehicle() || player.asEntity().isOnGround()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (player.getMotion().isFlying()) {
|
||||
Vec3d vel = player.asEntity().getVelocity();
|
||||
|
||||
roll -= calculateRoll(player.asEntity(), vel.x, vel.y, vel.z);
|
||||
return 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 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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue