Skip to content

Commit

Permalink
#24 greatly improve camera movement in third-person
Browse files Browse the repository at this point in the history
still not perfect, but much better

Signed-off-by: der_frühling <[email protected]>
  • Loading branch information
der-fruhling committed May 12, 2024
1 parent d707991 commit ca38399
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.derfruhling.minecraft.create.trainperspective.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import net.derfruhling.minecraft.create.trainperspective.Camera3D;
import net.derfruhling.minecraft.create.trainperspective.Perspective;
import net.minecraft.client.Camera;
Expand Down Expand Up @@ -31,8 +32,8 @@ private float modifyRoll(float original) {
}

@Redirect(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setRotation(FF)V"))
public void modifyRotationsPrimary(Camera instance, float y, float x) {
if(entity instanceof LocalPlayer player) {
public void modifyRotationsPrimary(Camera instance, float y, float x, @Local(argsOnly = true, ordinal = 1) boolean isThirdPerson) {
if(entity instanceof LocalPlayer player && !isThirdPerson) {
var persp = (Perspective) Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(player);
ctp$zRot = persp.getLean() * Mth.cos((persp.getYaw() - y) * Mth.DEG_TO_RAD);
setRotation(y, x - persp.getLean() * Mth.sin((persp.getYaw() - y) * Mth.DEG_TO_RAD));
Expand Down

0 comments on commit ca38399

Please sign in to comment.